Hello,

i have a view with 3 fields:
- URL (exclude from display)
- Logo (an image)
- Title (output to be rewritten)

Not all of the result's items do have a value for the field URL. Depending on that i would like to rewrite the output of the field "Title". I don't see a way to do it in the "rewrite results" option as there does not seem to be a way to implement if-else-statements.

If the URL is available the title should link to that url else the title should link to it's original content.

Roughly coded something like this:

if ($url) {
   print '<h2><a href="' . $url . '">' . $title . '</a></h2>';
} else {
   print '<h2><a href="' . $link . '">' . $title . '</a></h2>';
}

I was hoping to find a hook to manipulate the output of a certain field but no success. Then I tried to fumble with template suggestions by using a version of views-view-field.tpl.php. But that does not feel right.

What would be the proper way to do this please?

Thanx

Comments

merlinofchaos’s picture

Status: Active » Fixed

The template or a preprocess of the template is the right way to do this.

Status: Fixed » Closed (fixed)

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