It would be nice, if there is a link form taxonomy (term) title linking to node

Comments

damienmckenna’s picture

There really should be.. at least an option per content type or something.

R.Hendel’s picture

I managed this by using Panels for displaying terms on taxonomy-term-pages.
In a pane I show a view handling the NAT-TID getting from panel argument.
On this way you can come back from Tax-Term to node.

Alice Heaton’s picture

Status: Active » Fixed

This feature already works - it's just not very intuitive (just took me a while to work it out...).

Say you have a content type T1 on which you can use vocabulary V. Using the NAT module you associate content type T2 to vocabulary V.

When you view a node of type T1 (either as a teaser of a page) you want the links to the terms of vocabulary V to point directly to the nodes of type T2.

In order to achieve this, go the NAT settings page (/admin/settings/nat) and enable "Make NAT terms in categories node views point to the associated node rather than the taxonomy page." ON CONTENT TYPE T1. Doing this on content type T2 (which seemed more intuitive to me at first) does not give the expected result.

ManyNancy’s picture

Status: Fixed » Active

Anselm Heaton, not the same thing. You're replacing the term page with the node, not linking from the term to the node. Does anyone have the snippet for this? Thanks.

kars-t’s picture

Status: Active » Fixed

NAT has an API for this.

To get a link from a terms page to a node you can use:

    $nids = nat_get_nids(array(arg(2)));
    echo l('Link to NAT node', 'node/' . key($nids));

For a link to the term you can use:

  $term = nat_get_term(arg(1));
  echo l('Link to NAT term', 'taxonomy/term/' . $term->tid);
ManyNancy’s picture

Status: Fixed » Active

Hi Kars-T, do you know how to get the link to display the node name rather than just 'link to nat node'. I think a node_load in this instance is wasteful, is there any other way to get the node name? Thanks.

kars-t’s picture

Status: Active » Fixed

Hi Nancy,

I don't know if the issue queue is the right place for this but let's explain :)
This is more about common Drupal programming and API usage.

You can load a node with the node_load() API function.
Than the required data is in $node->title. So you can rewrite the l() usage to:

    $nids = nat_get_nids(array(arg(2)));
    $node = node_load(key($nids));
    echo l($node->title, 'node/' . key($nids));

The code is untested but I think it will work and hope that helps.

I am closing this issue again.

damienmckenna’s picture

Status: Fixed » Needs work

I don't think this can be cleanly handled with Drupal 6 without doing some crazy regex rewriting whereas Drupal 7 has more API hooks for modifying the URL.

For Drupal 6 the only real way is to maybe do a hook_init() to see if the requested path matches a term-node relationship and then do a 301 redirect?

kars-t’s picture

@DamienMcKenna
Hi

could you please explain what you mean by "crazy regex rewriting"? If you want to provide a link this can be easily done with some php code. I don't see any reasons for a regexp.

ManyNancy’s picture

Hi Kars-T, thanks for your help, I understand my question was a little weird because I mentioned that node_load is an expensive operation for this because the link is not on a node page, but on a term page. So loading the node is really wasteful.

But since there's no elegant solution, I'm just going to use the term name, because hey, term name = node name. :D

anantagati’s picture

Status: Needs work » Fixed

Closing issue. If there is still problem, feel free to reopen.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.