I'm using views-view-fields.tpl.php to theme the output of a content type.

What I need to do is the below, except I don't know how to get 'url_for_this_item' without either printing all the variables and referencing it in a long array lookup, ie like $fields[smth][ddd][0][44][ui][uri].

Is there a simple, clean way to get the url in the template? I have tried outputting a link but then views still insists on giving the full link with an closing tag on the end. Of course, I can parse this and remove the closing tag but it just seems too hacky. Is there not a better way?

print '<a href="' . $fields[url_for_this_item] . '">';
    print $fields['title']->content;
    print $fields['field_this']->content;
    print $fields['field_that']->content;
print '</a>';

I want to to get the url for

  • 1
    could you explain your content structure a bit. and what are all these fields? Commented Jan 29, 2013 at 16:37

2 Answers 2


If I understood it right, you can simply add a new field in Views which holds the URL to the item. And then in the template file you can print this field as you described in you question.


use <?php print $fields['uri']->content; ?> to print the URL of the particular field. However this works when you have the File:path field added in your views

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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