By Ken Collins on
OK, I've read all of GreenAsh.net's articles on breadcrumbs and taxonomies, but I cannot figure out how to change a breadcrumb link. I have a simple category that has 3 primary items with 2 levels under each. I need to find out how to make any of the three top-level terms in my blog category show all the posts when clicked in the breadcrumb. For instance, making (taxonomy/term/2) really work like (taxonomy/term/2/all). Any ideas? TIA
Comments
Category module
You might look at GreenAsh's category module, but it only works for 4.7 at the moment:
http://drupal.org/node/39683
Also, the views module might be of interest. I'm looking forward to trying out both of these modules myself.
No way except by combining
No way in 4.6 except by combining the tid's.
Here is the syntax:
http://drupal.org/node/39109#comment-71947
You will be okay as long as you don't alias the urls. What I have noticed is that with aliased urls, the moment you combine the tid's, the breadcrumb link for the top term reverts to taxonomy/term/2 instead of the combined url/alias.
Ram, your famous on this
Ram, your famous on this topic :)
I understand what your saying about the aliases, but you know, what I'm really wondering if there is an elegant hack for the taxonomy module that would default /tax/term/x to an tax/term/x/all behaviour. Seems that would do everything nicely and when the breadcrumb links to just tax/term/x the module is really showing all.
Any ideas?
Ram, your famous on this
:(
You know, I like Drupal too much to either flame or be ungrateful to the developers, but, Drupal just doesn't do hierarchical sites with taxonomy terms well. Let me put it another way: Building a hierarchical site with taxonomy terms is a HORRIBLE CHORE in drupal. It could be extraordinarily easy if:
1.) pathauto provided a pattern for aliasing taxonomy_menu generated urls
2.) if taxonomy_menu (or taxonomy module) listed nodes on the term pages of those terms which serve as parents to child or sub-terms (see the latter part of this post).
But, I digress.
Mike Carter's taxonomy_vocabulary module does a fine job of giving you a listing page for a vocabulary- that is, it pulls in *all* the nodes tagged with *all* the terms in a vocabulary (tax/term/all behaviour). Once you install and enable the module, you need to create an alias for the vocabulary (taxonomy/vocabulary/1, where 1 is your vocabulary id aliased to www.yourdomain.com/whatever-page-you-want)
But- and this is a big but- if you also need breadcrumbs that match the url structure, it won't help you, as far as I know. I wonder if you actually meant urls instead of breadcrumbs in your post.
For myself, I have finally decided to use a static page as the index page for my hierarchical section that uses taxonomy terms and pull in the nodes using a php snippet.
I also think there is a very serious flaw in the taxonomy module implementation where every taxonomy term automatically gets a listing page, but will not list the nodes unless the nodes are *directly* tagged with that term. For example, if you have two terms in a vocabulary, and they have several sub-terms and you choose to tag a node with one of the sub-terms, the term page will not list the nodes- only the sub-term's page will. To get the node listing on the term page, you have to manually construct a url combining the sub-term ids and then alias it. To me, this beats the very logic of using a taxonomy tree as a hierarchy.
I did mean breadcrumb links, not URLs
Check it out for yourself...
http://metaskills.net/
If you click on one of the test articles, you will see that the URL path and the breadcrumbs are matching up, with exception to the "Heuristics" breadcrumb. Right now I dont have the alias in place for that one since I have the alias assigned to the navigation link which is using the system path /tax/term/2/all
My problems would be solved if I just could change the (default) behavior of the taxonomy module to show all. To me, that's what seems all the fuss is about.
Got It !!!!
Ahh, I knew it was there somewhere. In taxonomy.module, about 80% down in the function taxonomy_select_nodes() there is a line like this:
$tree = taxonomy_get_tree($term->vid, $tid, -1, $depth);
Change it to this:
$tree = taxonomy_get_tree($term->vid, $tid, -1, NULL);
It sets the depth to NULL which is the same as all. This gives me exactly what I wanted in my categories with working breadcrumbs in 4.6.x
Simply brilliant!
Your one line hack solves the cursed problem of parent term (at any level) pages not *automatically* listing the nodes tagged with their child terms or sub terms of those child terms. I tried it with a simple hierarchy several levels deep (parent term>>child term>>sub-term>>sub-sub-term) and it works perfectly, with the top level parent term giving perfect breadcrumbs.
On a more sober note, I noticed a slight inconsistency in the ordering of the nodes on the term pages of immediate parents. But, I will live with that.
Perhaps you could submit this as a patch to taxonomy module and see what the developers have to say.
Thank you very much once again.
And, before I forget, that's a stunning, stunning theme you have.
A nicer way?
The only problem with your hack is that it will break the functionality of anything using $depth.
A neater solution would be to change the default value for $depth in the function:
function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $pager = TRUE) {becomes
function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 'all', $pager = TRUE) {--
Artemis Studios | Artemis Agency
this works if you change 'function taxonomy_term_page'
This neater solution seemed to work for me, but I had to change the following line in taxonomy.module as well.
I just used global search and replace for $depth = 0 to $depth = 'all' and that seems to have done the trick. I haven't come across any problems yet.
only change taxonomy_term_page()
Since the $depth variable gets passed on, there is no need to change the one in taxonomy_select_nodes() or taxonomy_get_tree(), just in taxonomy_term_page()
from:
function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {to:
function taxonomy_term_page($str_tids = '', $depth = 'all', $op = 'page') {that's all.
I'd like to see this changed in core, to me it is a more sensible default.
Nice hack .. works ! But I
Nice hack .. works !
But I think that is better if I insert the "tertiary term 1" only, automatically Drupal insert his parents (secondary term 1 and primary term 1 )
Can anyone say how these
Can anyone say how these hacks might impact the views generated with the views module?
THIS WORKS-YOU RULE
I didnt sleep last night thinking about this.
Great easy solution . worked for 5.7 . You guys rock .
(beware : first Edit taxonomy.module , then Disable Taxonomy from modules list , and then Enable it again, (hit a www.domain.com/cron.php in between) then you ll have it.
GET THAT IN CORE ASAP Guys! webchick , chx , dries , anyone.
Great!
I upgraded to 5.2 and use dhtml_menu with taxonomy_menu.
I clicked on "display dependents" and each category (with a clean URL) shows all child nodes. No hacks.
Very nice!
hacks don't work in v5?
Can't get these hacks to work in v5.1 - the main categories don't show sub-category nodes. Please advise.
yes they do
My hack works anyway.
If it doesn't work at first, I suspect that you are using the taxonomy_breadcrumb module, which overrides this function (taxonomy_term_page). Just make the changes there as well.
--
Ross Kendall
UK based Web and IT consultant specialising in Free and Open Source Software technologies.
http://rosskendall.com
None of these hacks are
None of these hacks are working for me either, nor do term/1/all or term/1/9999. Any advice?
Ross, you ROCK
Thanks for the hack, and the pointer about Taxonomy Breadcrumbs.
Works perfectly in my 5.1 install.
You just solved a major headache.
Great ... except with localizer module
This works great. The only problem is, when I activate the localizer module, even though I've hacked the pre-patched taxonomy.module, languages other than English lose the depth. There may be other modules that need to be hacked there, too.
It does work with v5.1
The changing of depth from 0 to all has worked for me: Content of Sub-Categories is shown by accessing term/X.
Subscribing, greetings,
Subscribing, greetings, Martijn
How about 6.x?
Anyone have a solution to this which works in 6.x? I tried editing taxonomy_select_nodes as per above but it didn't seem to work.
oops, I should have looked
oops, I should have looked around a bit more, I answered my own question. Editing taxonomy_term_page as per above still works perfectly, the function definition has simply moved from the taxonomy.module file and is now found at the top of the taxonomy.pages.inc file instead.
yes it works!
Thanks a bunch jameyc, you saved me a lot of time of poking around!!
It would be nice to add a checkbox for this (basically passing depth all vs 0, I guess) in future versions of Drupal.
Yes, works very
Yes, works very well.
Question... This will get overwritten when there is an update, correct?
Many comments ask for a
Many comments ask for a request for change in core regarding this functionality. And, although quite old, this thread seems to score high when searching for this behaviour, so I thought it would be handy to just post a link to that request: #37519: taxonomy depth support.
In short: in D6 use the hack above, in D7 use views...
got it working...manually
I got this working through an alias but it was a manual fix for every parent term. Basically, I went to /admin/build/path/list
, found the term I wanted to enable children for and clicked edit. Then just append /all to the end of the system path.
Example:
change
alias: myterm
system: taxonomy/term/234
to
alias: myterm
system: taxonomy/term/234/all
I haven't figured out an automated way to do this through the UI, but I'm planning to write a MySQL query to mass update my parent term aliases which are not child-enabled.