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


Try this snippet:

$node = menu_get_object();
if(is_object($node)) {
  $title = $node->title;
  echo '<a class="voacb-link" href="/yourpath">View all '.$title.'</a>';

Update 1:

Ok so here is a suggested workflow:

Create a taxonomy term reference field in the content type you want to place the linik into. Select "Books" as the vocabulary so that this field can reference the terms of the "Books" vocabulary. Let the machine name of thie field be "field_book_reference".

Now have a go at the snippet below:

$node = menu_get_object();
if(is_object($node)) {
  $title = $node->title;
  $book_tid = $node->field_book_reference['und'][0]['tid'];
  echo '<a class="voacb-link" href="/taxonomy/term/"'.$book_tid.'>View all '.$title.'</a>';

You may place this snippet anywhere that accepts php code. better, create a php block and place the block in a panel.


There's a default path that links to taxonomy/term/term_id. For instance if the term_id for the term Self help books is 42, the following path will list all self help books.


Now, to replace this with the appropriate string, navigate to:

Home » Administration » Configuration » Search and metadata » URL aliases

and specify that Self help books should be an alias for taxonomy/term/42.

First, make sure all nodes that you want listed as self help books is tagged with the tag Self help books.

Then, to create a link to the nodes tagged with a specific term based upon vocabulary, you need to install and enable the Token module and the Token Filter module (unless you've already done so).

Next navigate to:

Home » Administration » Configuration » Content authoring » Text formats

and click Configure on the text format (or formats) you plan to use. Under Enabled filters. make sure the filter named Replace tokens is activated.

You can now see the what tokes that exist by going to:

Home » Administration » Help » Token

and expand the Nodes item. Let us say that your book category field is named node:field_book_category.

Then, if you put an HTML link like this somewhere on a page tagged with Self help books:

<a href="/[node:field_book_category]">View more [node:field_book_category]</a>

you will get a link back to a page listing all nodes tagged with Self help books.

This will of course work with any other taxonomy term (e.g. sport books, cooking books, etc.) as well. However, the node can only be tagged with a single term from a particular vocabulary for this method to work.

Note: For this to work, the node must actually be tagged with exactly one taxonomy term from the relevant vocabulary. You can easily check that the node is tagged this way: When you view the content of the node, the taxonomy term or terms it is tagged with is automatically inserted by Drupal with link to a list of all nodes tagged with the term. If this link does not appear, then the node is untagged. If multiple links appear, then there are multiple taxonomy terms. If the node is untagged, there will be no token replacement and the token will appear as plain text. If the node is tagged with multiple terms, then the token will expand into a list of taxonomy categories, and can no longer be inserted in a single link.

PS: As an alternative solution you can override the template for the node (node.tpl.php), you can replace the simple link mentioned in the previous paragraph with the string "View more" followed by the link. This also work if there are more than one tag from the vocabulary on the page.

  • If I go to the alias URL I created for the taxonomy term (site.com/categories/selfhepbooks) all the nodes I tagged with that category show with a title, summary, and a read more link. So it is getting tagged. – dcp3450 Oct 6 '13 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.