How do I make a template file for a specific display in a view when I have multiple displays of the same type

StackOverflow https://stackoverflow.com/questions/9106817

Question

I have a view that I am using for articles on the front page (View called Frontpage Top).

in one BLOCK display (named: Top Story) it just selects the most recent article. in the other BLOCK display (named: Top 5 Stories) it selects the 2nd-6th most recent.

I need to make a template for the single top story, and then another to display the other 5.

this template: views-view--Frontpage-Top.tpl.php works, but it's being used for BOTH blocks.

The only way I know how to do this is with multiple views, but these are so closely related I'd like to keep them in one. Is this even possible, and if so what would the filename look like?

it doesn't seem to be documented in Views2 ( http://drupal.org/node/352970 ) and this ( Drupal: Views, can the displays have different styles for the view? ) is close but not the same.

If the "right" way is to create multiple views I am ok with that, but I cannot find a resource saying that and I'd prefer not to if I don't have to.

Thanks!

Was it helpful?

Solution

Each display can be themed independently from another. In the Views admin, go to the display you want to customize and click on "Theme: Information". This will show you all possible templates and naming options you have. See the image below:

Views Theming

If you see in the image above, you can create a template for specific displays in a view. For example, all of my displays in this view are Page displays. So to style the "Business Cards" display (the 2nd display), I could use "views-view-grid--Vendors--page-2.tpl.php" to change the Style Output. The page-2 specifies that you want the template to handle your 2nd page display in this view.

If you need more information, take a look at Views 2 Theming Documentation

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top