aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2011-05-17 00:31:52 -0300
committerSilvio <silvio@devlet.com.br>2011-05-17 00:31:52 -0300
commitbf8fef777e4ece714a4f526b8a5b6007e3e48bde (patch)
tree034c5be6a719cff7a20aa48602920ecad967ca00
parentf9efcc27594d055093858a2da8c4400ffe8dbf08 (diff)
downloadtaxonomy_node_tree-bf8fef777e4ece714a4f526b8a5b6007e3e48bde.tar.gz
taxonomy_node_tree-bf8fef777e4ece714a4f526b8a5b6007e3e48bde.tar.bz2
Adding taxonomy_node_tree_trail()
-rw-r--r--taxonomy_node_tree.module29
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;
+}