By bfbryan on
Could someone give me a hand? I am trying to run a query to display ONLY the taxonomy term parents with active links to a page showing all the child nodes within the parent node.
This is what I've got currently but I have 2 issues. 1) it is showing all the terms (parents and children) and 2) I need each link to be dynamic or utilize the call back function.
function companysearch_industry () {
$vocabulary_id = 2;
$result = db_query("SELECT a.tid, a.name FROM {term_data} a LEFT JOIN {term_hierarchy} b ON a.tid = b.parent
WHERE a.vid = $vocabulary_id GROUP BY a.tid, a.name ORDER BY a.name");
$items = array();
while ($category = db_fetch_object($result)) {
$items[] = l($category->name, 'industry');
}
print theme('item_list', $items);
}
Comments
http://api.drupal.org/api/5/f
http://api.drupal.org/api/5/function/taxonomy_get_parents
http://api.drupal.org/api/4.7/function/taxonomy_get_parents_all
Parent Terms
I don't want to get the parents of a specific tid rather a specific vid. Is that possible to do? Any help on how I make them into dynamic links to show the children?
Vocabularies can't have
Vocabularies can't have parents, so I'm a little confused. However, you can use this function to retrieve the terms for a specific vocabulary:
http://api.drupal.org/api/5/function/taxonomy_get_tree
It might be best if you browsed the taxonomy functions. Perhaps you'll find what you're looking for:
http://api.drupal.org/api/5/file/modules/taxonomy/taxonomy.module
May be this is could help
May be this is could help you.
Display Parent Taxonomy Terms
Only Parents, if the father is defined: only children of that parent. I believe that this is it that your you need.
This case is to be used with arguments in the URL, like: " /case/%/list "
But you can to use without arguments without changing nothing.
The only thing to modify is the the first line, the vid of the vocabulary to use.
Luck
Or drop down list:
How would I use this with
How would I use this with this thread?
http://drupal.org/node/133223
I am trying and learning... :)
Eric
http://bowwowimport.com/exhaust
may the sun be on your back and Drupal in your face.
I'd Like to Know too
It would be great to do something like this:
Node Title
Category name: parent-term>term, parent-term>term
Node Body
Skipping the current term if possible, so it only shows the other terms that the node maybe under.
Found a solution!
This is what I ended up doing after tons of research: http://drupal.org/node/235818#comment-865908
Needing sister-terms
Needing sister-terms solution through parent..
Subscribing, greetings, Martijn
Is thr a way for printing
Is thr a way for printing child terms only ?
Or skipping the first term will also do in my case
Getting only parent terms using vocabulary id
Please use the below function it will return result array. You can change the $depth accordingly.
taxonomy_get_tree($vid, $parent = 0, $depth = 1);
print_r(taxonomy_get_tree($vid, $parent = 0, $depth = 1));
This will print the result array.