taxonomy

how to access [name] of first object?

  1. (
  2.     [3] => stdClass Object
  3.         (
  4.             [tid] => 3
  5.             [vid] => 1
  6.             [name] => puppy
  7.             [description] =>
  8.             [weight] => 0
  9.         )

Fix for Argument handling code for a view taking in TID as argument, trying to get the parent TID to be returned (if it has)

  1. // note that this only gets the immediate parent
  2. if ($args[0]){
  3.         $parents = taxonomy_get_parents($args[0]);
  4.         if ($parents) {
  5.                 foreach ($parents as $parent) {
  6.                 $parentID = $parent->tid;

Function to retrieve a certain level from a vocabulary

  1. function taxonomy_get_level($vid, $level) {
  2.   static $levels;
  3.  
  4.   if (!isset($levels[$vid][$level])) {
  5.     $tree = taxonomy_get_tree($vid);
  6.     foreach ($tree as $term) {

get vocab depth

  1. function taxonomy_vocabulary_get_depth($vid) {
  2.   $tree = taxonomy_get_tree($vid);
  3.   foreach ($tree as $term) {
  4.     if ($term->depth > $depth) {
  5.       $depth = $term->depth;
  6.     }
  7.   }

taxonomy_select_nodes doesn't work for me! :(

  1.    $result = taxonomy_select_nodes(Array($termkey), 'or', 0, FALSE, 'n.sticky DESC, n.created DESC');
  2.     drupal_set_message('fetchimages_getnodelist(): got result');

Show node parent terms

  1. <?php
  2. // split out taxonomy terms by parent
  3. function bowwowtheme_liquid_print_terms($nid) {
  4.   $terms = taxonomy_node_get_terms($nid);
  5.   $links = array();
  6.   $processed = array();
  7.   if($terms){

Argument handler for terms restricted to vocabulary

  1. function taxonomy_combination_views_arguments()
  2. {
  3.   $arguments = array();
  4.   foreach (taxonomy_get_vocabularies() as $vocabulary) {
  5.     if($vocabulary->taxonomy_combination_show)
  6.     {

Fix for Turn a flat taxonomy-tree into a real tree

  1.  $terms = taxonomy_get_tree(9);
  2.  
  3.   // build a map tid->term
  4.   $tree = array();
  5.   foreach ($terms as &$term) {
  6.     $tree[$term->tid] = &$term;
  7.   }
  8.  
  9.   // add child links to every node

Turn a flat taxonomy-tree into a real tree

  1.  $terms = taxonomy_get_tree(9);
  2.  
  3.   // build a map tid->term
  4.   $tree = array();
  5.   foreach ($terms as &$term) {
  6.     $tree[$term->tid] = &$term;
  7.   }
  8.  
  9.   // add child links to every node
Syndicate content