dcp3450
dcp3450

Reputation: 11187

Can I create a link to a nodes taxonomy page in Drupal?

I have a page that has a single category applied to it, for this example, "Self Help Books".

I want to put a place on content type that display a "view all [insert category here]" that links to that category listing page. I was hoping I could do something like:

<a href=%taxonomyLink:books--self-help-books%>view all%taxonomy:books%</a>

and it would pull in the category for anything using that content type. I'm using the panels modules so I had planned on placing this in a panel the content type was using. Is any of this possible?

I thought about creating a block and placing that in a panel in the panels module.

(also, if you can't tell, I'm pretty fresh to Drupal.)

Upvotes: 0

Views: 681

Answers (3)

hugronaphor
hugronaphor

Reputation: 985

You don't need to write code for this. If you using panels .. Find a way to put a right relationship in context for needed taxonomy term, after that you will have all the needed tokens (%placeholders) to build your content.

Upvotes: 0

Tomas Tibensky
Tomas Tibensky

Reputation: 821

you can use simple drupal api function to achieve that.

  1. first you will need to load needed taxonomy term (lets say that 123 is taxonomy term ID)
  2. then build the link

here is the code:

$term = taxonomy_term_load(123);
$link = l($term->name, 'taxonomy/term/' . $term->tid);

you can also find more about l() here https://api.drupal.org/api/drupal/includes%21common.inc/function/l/7

Upvotes: 3

lips
lips

Reputation: 1

This Drupal docs page lists several modules that assist in displaying related content, via a few different methods.

As of now, the most stable 7.x compatible terms-based module appears to be Similar by Terms.

There are ways to achieve this without installing an additional module, but this will satisfy your requirements as-is.

Upvotes: 0

Related Questions