filter

jQuery Disaster

  1. /* This bit of code is inside a filter's processing function:
  2.  
  3.       $mod_path = drupal_get_path('module', 'counter');
  4.      
  5.       drupal_add_js($mod_path .

Fix for Filter hook implementation

  1. # Problem caused by line 750 in form.inc
  2.  
  3.   if (!isset($form['#validate'])) {
  4.     if (function_exists($form_id . '_validate')) {
  5.       $form['#validate'] = array($form_id .

Filter hook implementation

  1. # DRUPAL 7
  2.  
  3. /**
  4.  * Implements hook_filter_info().
  5.  */
  6. function xbbcode_filter_info() {
  7.   $filters['xbbcode'] = array(
  8.     'title' => t('Extensible BBCode'),
  9.     'description' => t('Renders sta

Custom Filter to remove HTML Comments

  1. /**
  2.  * Implementation hook_filter().
  3.  */
  4. function custom_filter($op, $delta = 0, $format = -1, $text = '') {
  5.   switch ($op) {
  6.     case 'list':
  7.       return array(0 => 'HTML Comment Removal Filte

Example Block Filter

  1. <?php
  2. $match = FALSE;
  3. $url = request_uri();
  4. $types = array('mycontenttype' => 1);
  5. if (arg(0) == 'node' && is_numeric(arg(1))) {
  6.   $nid = arg(1);
  7.   $node = node_load(array('nid' => $nid));
  8.   $ty

Find a taxonomy term in a specific vocabulary

  1. foreach ($node->taxonomy as $term) {
  2.   if ($term->vid = 1337) {
  3.     return $term->tid;
  4.   }
  5. }

Get terms in a specific vocabulary

  1. /**
  2.  * Given a node's taxonomy terms, filters out the terms in the specified
  3.  * vocabulary.
  4.  *
  5.  * @param object $terms The node's taxonomy terms

add input format to body

  1. <?php
  2. // add input format to custom node form
  3. // this goes in hook_form
  4.  
  5. //Get metadata for this node type defined in hook_node_info()
  6. $type = node_get_types('type', $node);

views export code

  1. $view = new view;
  2. $view->name = 'Rulings';
  3. $view->description = '';
  4. $view->tag = '';
  5. $view->view_php = '';
  6. $view->base_table = 'node';
  7. $view->is_cacheable = FALSE;
  8. $view->api_version = 2;

turn multiple selectbox into checkboxes

  1. function hook_form_alter($form_id, &$form) {
  2.   if (isset($form['view']['#value']->exposed_filter) ) {
  3.         $view = $form['view']['#value'];
Syndicate content