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.
Hello,
I'd like to get a taxonomy term's parent term so it could it be used in Custom Breadcrumbs for Views. At #628796: Breadcrumb setting for: Home > Taxonomy Parent Term > Taxonomy Child Term a possiblity of developing a new token for this is mentioned, unfortunately I'm not much of a coder so a bit of help would be greatly appreciated...
Comments
Comment #1
Dave ReidComment #2
Summit CreditAttribution: Summit commented+1 for this token! to use it in a page-title.
I would like the taxonomy parent term and top term in the taxonomy tokens, it's missing right now.
greetings, Martijn
Comment #3
JimNastic CreditAttribution: JimNastic commentedI have a similar requirement. I'd like to see a list of all parent terms in situations where there are multiple parents. By the way comment #9 here: http://drupal.org/node/654766 seems to be seeking to do something similar
Comment #4
willeaton CreditAttribution: willeaton commented+1 for this token for use in page titles
Comment #5
willeaton CreditAttribution: willeaton commentedOK, I have written some code that worked for me although Im sure it requires a whole host of other changes to make it more accurate or something...
In token/token_taxonomy.inc I have made the following changes...
has changed to
and further down...
has changed to...
Comment #6
Branndon CreditAttribution: Branndon commentedThanks Willeaton, that gets [parent-term] to show up on my admin/help/token page, but not in my custom breadcrumbs page where I can use tokens to create breadcrumbs. Any ideas why not? When I put [parent-term] in the custom breadcrumbs, it shows me [parent-term] not any token value.
Comment #7
willeaton CreditAttribution: willeaton commentedSorry, I don't really understand how tokens work. I just took the existing file, added a few lines and the new token appeared for me in the nodewords module configuration page.
Comment #8
Beerlover88 CreditAttribution: Beerlover88 commented+1
Comment #9
alexmoreno CreditAttribution: alexmoreno commentedi guess everyone knows, but never edit the code of a contrib. or core module, unless if you are building a patch and you really know what you are doing.
Instead, for this case you can create custom tokens in different ways: