From bf8fef777e4ece714a4f526b8a5b6007e3e48bde Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 17 May 2011 00:31:52 -0300 Subject: Adding taxonomy_node_tree_trail() --- taxonomy_node_tree.module | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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; +} -- cgit v1.2.3