Iain Urquhart

Taxonomy

taxonomy:node_url

Fetches the node's url according to Taxonomy from a given entry_id

{exp:taxonomy:node_url entry_id='{entry_id}' tree_id='1'}

Example output:

http://example.com/template_group/url_title

Tag Parameters

tree_id=

tree_id="1"

The id of the tree you want to fetch

entry_id=

entry_id="{entry_id}"

The entry_id of the node to return the url for

node_id=

node_id="12"

The node_id of the node to return the url for

hide_dt_group

hide_dt_group="yes"

Hide/remove default template group from urls generated by Taxonomy.


Tips

If you find the following markup unsightly:

<a href="{exp:taxonomy:node_url entry_id='{entry_id}' tree_id='1'}">{title}</a>

Create a new snippet with the name taxonomy_url_title with the tag {exp:taxonomy:node_url entry_id='{entry_id}' tree_id='1'} as the Variable Content

This will 'clean' the above markup to:

<a href="{taxonomy_url_title}">{title}</a>

Remember though, in this example, we're specifying the tree id, so if you want to use for multiple trees, you'll need to create multiple snippets.


Notes

The first time the tag is called, it stores an array of each node [entry_id] => [node_url] in the user's session. Each subsequent request is accessed directly from there so the amount of queries from 20 instances of this tag on the same page is at most, 1 query.

It's also worthwhile noting that so long as a node exists for the entry, the url generated by this tag will keep itself updated should the template names be updated, or the url_title of the entry be updated.

This tag should also work in search results to bring the user to the correct template as specified in Taxonomy. However, you may need create a workaround with conditionals if you have multiple trees using the same weblogs.

Want to say 'thank you'?

If you find any of my work useful, feel free to make a donation amount of your choosing via PayPal — or if you like, purchase a copy of Introvert from Devot-EE and you'll get something in return :)

↑ Back to top