diff options
-rw-r--r-- | taxonomy_node_tree.module | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/taxonomy_node_tree.module b/taxonomy_node_tree.module index c34c8ea..9288de4 100644 --- a/taxonomy_node_tree.module +++ b/taxonomy_node_tree.module @@ -252,3 +252,32 @@ function taxonomy_node_tree_list($term, $id, $class, $baselink = NULL, &$level = return $output; } + +/** + * Build an array with a node and it's parent terms. + * + * @param $parents + * Direct or all parent terms. + */ +function taxonomy_node_tree_trail($nid, $tid, $parents = 'direct') { + $trail = array(); + + // Add term hierarchy + if ($parents == 'direct') { + $function = 'taxonomy_get_parents'; + } + else { + $function = 'taxonomy_get_parents_all'; + } + + // Build array + foreach (array_reverse($function($tid)) as $term) { + $trail[] = $term->name; + } + + // Add node title + $node = node_load($nid); + $trail[] = $node->title; + + return $trail; +} |