0

I am using Drupal 7 and the Views module. I made a very simple page showing nodes with the Views module, where I want to show only one field, which contains taxonomy terms.

I want to rewrite standard link from this page to my own variant. I selected "Rewrite results" and wrote my link. In the view, those links are not changed: they are going to taxonomy term pages.

I know that if I used a view showing taxonomy terms (not nodes), I could checkout the field for standard taxonomy output, but in a node view there is no such possibility.

0

You can do that like follows.

Go to your view and click on filed (having taxonomy) to change the settings.

  1. Change the Formatter option to plain text. (If you choose Formatter as 'Link' that won't work even you write Rewrite Results')
  2. Check output this filed as link and enter your path. Or you can also use'Rewrite the output of this filed'

enter image description here

That's it.

0
  1. Find the machine name for your vocabulary. (Hint: go to admin/structure/taxonomy and click "edit" next to the vocabulary. The vocabulary's machine name will appear in the URL).
  2. Copy page.tpl.php into your theme folder and rename it page--vocabulary--[machine name].tpl.php. Of course replace "[machine name]" with the actual machine name.
  3. If page.tpl.php doesn't already exist in your theme folder, grab a copy from your base theme, if you are using one, or the modules/system folder. (If you are customizing more than one vocabulary, just repeat this step for each.)
  4. Open template.php in your theme folder (create it if it doesn't exist) and paste in the function below. Replace "THEME" with the name of your theme.

By adding the below code, you are "suggesting" a new template be used that deals specifically with the vocabulary being loaded.

function THEME_preprocess_page(&$vars) {
  if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
    $term = taxonomy_term_load(arg(2));
    $vars['theme_hook_suggestions'][] = 'page__vocabulary__' . $term->vocabulary_machine_name;
  }
}
  1. Clear all caches.

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.