Hi,

Question about Drupal & views?

In a view i have a field that is a taxonomy term, I'd like to write an if statement that checks the value of the Taxonomy and replaces the output in the display to a different value.

EX:

Taxonomy terms says "rush", I'd like to change it to "fix now" 

How can i do this?

Thanks,

Stephen

Comments

nitin.k’s picture

1. Create a file in the current theme templates named as : views-view-field--( taxonomy field name -  please replace _ with - ).tpl.php

2. Paste below code.

<?php


// Note: Please note field_tags is a taxonomy term field name.

// print"<pre>"; print_r($row->field_field_tags[0]['rendered']['#title']); exit;

if ($row->field_field_tags[0]['rendered']['#title'] == 'tag1') {
  print $row->field_field_tags[0]['rendered']['#title'] = "tag2";
}