Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By dericknwq on
By default, when we create a taxonomy structure like:
Vocab:
- Main Cat
- - Sub Cat
- - Sub Cat
- Main Cat
- - Sub Cat
- - Sub Cat
- Main Cat (id: 3)
- - Sub Cat
- - Sub Cat
How can we have taxonomy/term/3 list all the nodes in tid 3 as well as the nodes in the children terms?
Comments
_taxonomy_term_children()
Look for _taxonomy_term_children() and related functions in taxonomy.module. You might use code like the following code with _get_nodes_by_vocabulary_and_term($vid, $term_child) being a recursive function you create.
petermoulding.com/web_architect
petermoulding.com/web_architect
Is your code meant to be
Is your code meant to be plugged into the template files? There are quite alot of things I wish to do and am resorting to just coding directly in the template files. I'm not too sure if that should be the way though. :(
And by default taxonomy/term/x will already query for the nodes. How can I stop it from doing so? Otherwise, I will be querying twice right?
Dirty but effective. Open
Dirty but effective.
Open modules/taxonomy.module in a text editor (back it up at first!!)
Find the line:
and repace the last $depth with NULL
It's working in Tabernil.com.
Regards.
PS: This answer was found somewhere in drupal.org, I don't remember where.
Thanks for that, I'm really
Thanks for that, I'm really trying to refrain from touching any of the core modules. In fact I had the idea that Drupal was set up in a way that they has to be things that can be "hooked" on instead.
page.tpl.php
I used the code in page.tpl.php. If you put code into a function then call the function, put the function in template.php as template.php is called before all the other parts of your template.
There are several related functions in taxonomy that can be used by templates. Read through them to see what data they return. Some return raw data and some return formatted HTML. The functions can also be used in blocks and content when you want very specific detail.
petermoulding.com/web_architect
petermoulding.com/web_architect
Use the 'all' parameter
Simply add the 'all' parameter to your URL.
So in your example, go to: taxonomy/term/3/all
Taxonomy Force All
I have created a new module to enable this behaviour: http://drupal.org/project/taxonomy_forceall