I created a Block showing the latest 3 articles ("pets") as teaser (not using fields). The content type has a field type which can be dog, cat or other.

Now i want to show only one of each type: one dog, one cat and one other. I don't have any idea how i can do that... I have some filter criteria (content-type=pet, available=yes, public=yes) and sort criteria (content:date_arrived desc) and limited to 3 items.

Thanks for any help / hint!

I'm using drupal 7 and the newest views-module.

2 Answers 2


I thing it's difficult to make just with the views UI (the aggregation will not work) If you don't want the solution of Anil Sagar, i have another solution with some theming.

  • Go to format => setting : In Grouping field Nr.1 select your field type (left)
  • Now your result will by group by type (dog, cat and others) You can see an extrat of the output. (right)

enter image description here

  • Go to Advanced setting => Other => Theme information

views settings 3

  • Copy / Paste views-view-list.tpl.php in your new template and make some modification

     <?php print $wrapper_prefix; ?>
     <?php if (!empty($title)) : ?>
       <h3><?php print $title; ?></h3>
     <?php endif; ?>
     <?php print $list_type_prefix; ?>
     //Add this
     <?php $x = 0; ?>
     <?php foreach ($rows as $id => $row): ?>
        <?php if($x < 1): ?>    
        <li class="<?php print $classes_array[$id]; ?>"><?php print $row; ?></li>
        <?php $x++; ?>
      <?php endif ?>  
    <?php endforeach; ?> 
    <?php print $list_type_suffix; ?>
    <?php print $wrapper_suffix; ?>

And you'll have what you wanted:

views settings 4

  • Great, that worked! Thanks a lot! I just had to force using fields because i set it to display unformatted list of teasers and remove title output in template.
    – nappo
    Sep 22, 2012 at 9:21

I think below solution should work.

  • Create three block views.
  • Each will have three different type filters -- 1st view block (Type: dog) -- 2nd view block (Type: cat), 3rd view bloc (Type: Other)
  • Restrict number of nodes to 1 in pager settings.

Enable all three blocks one below other or use views attachment feature as explained here.

One more solution for this is using Aggregation feature in views. I haven't tried this but should work i think. Give it a try !

  • that would work, but with that methods i will have to edit my hole theme or use dirty tricks. i hope there's a simpler method...
    – nappo
    Sep 21, 2012 at 12:30
  • I tried aggregation as i thought it would be the right place to start, but didn't figure out how to use it to get what i want
    – nappo
    Sep 21, 2012 at 12:40

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.