I have a block view which filters for a specifiy content-type. I'd like to fully style it myself and also write the html myself it outputs. So I went and created the file views-view-fields-header-image-slider--block.tpl.php in /templates.

Now, I do have the $view object but no $field etc. Also var_dump($view->field['description_title']); result in Null.

I'm a bit confused how I can access the fields nor properly so I can render the image + description and all the other stuff.

  • look in theme:information in advaced settings column in your view, is the last row, then make a field.tpl.php template for each field you wish
    – pinueve
    Commented Jun 12, 2017 at 19:00

1 Answer 1


If you haven't already, look at the theme information in the Advanced section on your Views admin page. It's near the bottom.

You should see a list of theme templates for each field, along with a row style that should have information for each row. Each field is also linked to a sample template, and you will also notice the list of file names the view is searching for, from general to specific. I've attached an example of what it looks like.

Looking at my own now... You might also want to try the "style output," though in my case I did everything through the field content template. enter image description here

Edited to add:

I don't have enough reputation to comment yet, but it looks like there is some useful info on How do I access a field value in the $row variable in a field view theme template?

Simply out, here are the two approaches from over there:

$field = $row->{$field->field_alias}
$rendered_field = $view->render_field($fieldname, $view->row_index);
  • but how do I easiyl access the fields? I mean, sure I can work my way through the array but that just looks wrong. There must be some kind of mapper in drupal 7. E.g. print $row->field_field_description[0]['raw']['value']; works but it just looks wrong. I'm kind of "bruteforcing" my way to the value instead of using whatever nice mechanism is coming with D7. I'm missing some nice getter method or whatever.
    – xotix
    Commented Jun 14, 2017 at 11:13

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.