taxonomy

hook_nodeapi

  1. function hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  2.   switch ($op) {
  3.     case 'insert':
  4.       $node->taxonomy = array(1 => taxonomy_get_term(1));
  5.       node_save($node);
  6.       }
  7.       b

Select vocab by name.

  1. /**
  2.  * Utility function to select a vocabulary by name rather than vid.
  3.  *
  4.  * @param $name
  5.  *   The name of the vocabulary to retrieve.
  6.  *
  7.  * @return
  8.  *   The $vid of the vocabulary name refer

Code

  1. $name = '';
  2. foreach ($node->taxonomy as $item) {
  3.   if ($item->vid == 10) {
  4.     $name = check_plain($item->name);
  5.     break;
  6.   }
  7. }

Fix for Fix for Fix for Fix for Gets list of taxonomy terms

  1. <?php
  2. $vid = 3;  // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
  3. $items = array();
  4. $result = db_query('
  5. SELECT tn.tid,
  6. ( SELECT count( x.tid )
  7. FROM term_n

Fix for Fix for Fix for Gets list of taxonomy terms

  1. <?php
  2. $vid = 3;  // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
  3. $items = array();
  4. $result = db_query_range('
  5. SELECT tn.tid,
  6. ( SELECT count( x.tid )
  7. FROM

Fix for Fix for Gets list of taxonomy terms

  1. <?php
  2. $vid = 3;  // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
  3. $items = array();
  4. $result = db_query_range('
  5. SELECT tn.tid,
  6. ( SELECT count( x.tid )
  7. FROM

Fix for Gets list of taxonomy terms

  1. <?php
  2. $vid = 3;  // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
  3. $result = db_query_range('SELECT tn.tid, (
  4.  
  5. SELECT count( x.tid )
  6. FROM term_node x
  7. LEFT

Gets list of taxonomy terms

  1. <?php
  2. $vid = 3;  // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
  3. $items = array();
  4.  
  5. $terms = taxonomy_get_tree($vid);
  6. foreach ( $terms as $term ) {
  7.   $count

Enable WYSIWYG for term descriptions?

  1. function my_module_form_alter(&$form, $form_state, $form_id) {
  2.    
  3.     switch ($form_id) {
  4.                
  5.           case 'taxonomy_form_term':
  6.             $form['description']['#WYSIWYG'] = TRUE;
  7.                 break;
  8.     }  //switc

Fix for Remove 'Vocabularies' fieldset

  1. /**
  2.  * Implementation of hook_form_alter().
  3.  */
  4. function mymodule_form_alter(&$form, &$form_state, $form_id) {
  5.   if ($form_id == 'nodetype_node_form') {
  6.     // Remove 'Vocabularies' fieldset.
  7.  
Syndicate content