Project:Node Auto Term [NAT]
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

Comments

#1

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

#2

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.

#3

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.

#4

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.

#5

Status:active» fixed

NAT has an API for this.

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

<?php
    $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:

<?php
  $term
= nat_get_term(arg(1));
  echo
l('Link to NAT term', 'taxonomy/term/' . $term->tid);
?>

#6

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.

#7

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:

<?php
    $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.

#8

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?

#9

@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.

#10

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

#11

Status:needs work» fixed

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

#12

Status:fixed» closed (fixed)

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

nobody click here