views:

63

answers:

3

What I'm trying to achieve is very simple, but a bit difficult to explain:

  1. I want to create a view to return the last 5 nodes based on some condition
  2. The fields I want to show are "Title,Abstract & Thumb"
  3. I want to show the thumb for only the first node, I don't want the thumb to be displayed for the rest

Of course hiding the thumb via CSS is silly. What is the best way to achieve this?

+2  A: 

You need to use Views attachments. Google around to understand what an attachment display is. You don't need to install any special modules for the views module to get the attachment display.

An attachment display is a display type in Views (like Page, Block) except that it gets attached to a pre-existing view. So the first view you create a page display that shows the Title, abstract and thumb (and shows only 1 item). Let the attachment display be attached after the page display. It should have an offset of 1 (so that it skips the first item) and it should not have the thumb under fields (override the fields settings). It should show 4 items. Offset is a setting under Basic settings of views.

This will achieve your objective.

That said, hiding the last three images using CSS is not a bad idea either. Use the css injector module.

Sid NoParrots
Thanks! It worked, but my case is a bit more complicated:I have multiple display blocks under the same view. Each block displays 5 items from a different taxonomy. What I'm facing is that when I created the attachement it displays the same node all the time! Even though I have set argument inheritance. It does work when the argument is supplied by URL. But in my case, the arguments are embedded in the display block and not passed by URL
Ammar Ibrahim
A: 

Assuming Drupal 6.x...

Have you looked into building two displays:

  1. A page display, without the thumbnail field, limited to whatever number of items, offset = 1
  2. An attachment display with the thumbnail field, limited to 1 item, offset = 0
  3. Attachment settings: Position: Before; Attach to: Page

Sorry don't have time to write detailed directions at the moment. I'll check back later to see if this idea gets you started...

mikeker
Doh! That's what I get for not hitting "Post" before wandering off to read the web...
mikeker
Hehe, that's fine :) This is what NoParrots already suggested which works fine, but I need a solution to inherit none URL arguments
Ammar Ibrahim
A: 

You might want to edit the view template to achieve this end. It's a bit of a dark art, but it is probably the fastest way without making attachments. You'll most likely be editing views-view-fields.tpl.php. You can get more info about it by hitting the Theme: Information link in your view.

The view template will look empty at first (even after you copy in the code), but you can do a lot by looping through $view->results.

Chuck Vose

related questions