Community & Support

I want the first row of my view output to have a different style

I have a view set to display a brief list of teasers. I only want to display a thumbnail photo next to the first teaser. I can prevent the thumbnail from appearing with CSS, but I'd rather not download a thumbnail I'm not going to display anyway.

I'd prefer having a counter to track which row I'm iterating over in the PHP code, so the call for the photo thumbnail only occurs in the first row.

Any suggestions for how to tackle this display in Drupal?

Comments

Views Attachments

I'm assuming you're using Views 2. What you want to do is look into Views Attachments.

Basically create your view for the first row, set the sorting how you want it, and limit the results to one.

Then add a views attachment, overriding the fields to how you want the rest of the fields to work. Then in 'Items to display' set the 'offset' to 1 so you don't end up showing the first record twice. Then attach the view to your initial view.

This was a very quick run down, knowing the terminology now you should be able to find a better tutorial.

alternatively, just edit the

alternatively, just edit the views template file.

edit your view and use Theme: Information under Basic Settings to determine the appropriate file name to use. create a file with that name in your theme directory, edit it to use the logic you want (i.e. print the photo only in the first row), then clear your theme registry at /admin/settings/performance so the new template is recognized.

hth!