views:

27

answers:

1

A have a view created with Drupal's Views module, and have given it a Block display. It has the following fields:

  • first_name
  • last_name
  • professional_title

I understand that I can create a "[viewname]-block.tpl.php" file to provide a custom theme for this particular block, overriding the generic block.tpl.php template file. Within this [viewname]-block.tpl.php file, how can I pull out individual fields (eg, First name) so that I may theme them individually, giving them different classes? I've taken a look at $block, which yields $block-content, containing all fields, but this is as granular as I have managed to go so far.

Any help is appreciated.

+1  A: 

Go into the Views UI and navigate to the block view you're trying to theme.

Under basic settings (at the bottom of it in fact) you'll see a Theme Information link. Click it.

I'm copying and pasting the official description of what that does:

"This section lists all possible templates for the display plugin and for the style plugins, ordered roughly from the least specific to the most specific. The active template for each plugin -- which is the most specific template found on the system -- is highlighted in bold."

So find the template for the field you want to theme and click the link for it - you'll get code to copy and paste. The code will be really generic, but there are notes in the generated tpl file about how to pull more specific object data.

Hope that helps

Jared
Thanks for your help. I was having no success in searching for this solution.
ford