1

I have a Drupal 7 page View which returns one result while an attachment View (with offset 1) returns the rest. (First result displays title, body, image, etc. while the following rows only return title and trimmed teaser.) At this point, the View is returning the expected results.

The problem comes in when I wish to add a pager. Desired results would be the initial page returns the first result (styled uniquely) with next nine rendered through the attachment. ?page=1 and following would be the next 10 rows rendered through the attachment.

I am certain this must certainly be possible; but having difficulty achieving it.

1 Answer 1

0

Don't split them into two views. Use 1 view, without offset.

Simply use your view id followed by the class .views-row-1 in your CSS.

Ex: #view-id .views-row-1 .views-field-title { border: solid red };

If you need to have only certain fields to display on row 1, ex: body field only on row 1, then you'll need to create a template file for your view and just do a conditional.

Add field Global: View result counter

views-view-fields--[view-name]--[machine-name].tpl.php

<?php

if (strip_tags($fields["counter"]->content) == 1) {
   print $fields["title"]->content;    
   print $fields["body"]->content;
}
else {
   print $fields["title"]->content;    
}
3
  • No Sssweat, thanks much for your assistance. I've added the field, created the template and can confirm the content is being rendered through the template. However when using the statement if ($fields["counter"]->content == 1) { all content is rendered through else. (Although pager is functioning properly -- Thank you!) When condition is changed to if ($view->row_index == 0) {, the image is returned at the top of each page. Oct 19, 2017 at 20:25
  • @ConfusedDrupaler Since that didn't work, I think it needs to be if ($fields["counter"]->raw == 1) { and if that doesn't work either, try if (strip_tags($fields["counter"]->content) == 1) {
    – No Sssweat
    Oct 19, 2017 at 22:47
  • 1
    if (strip_tags($fields["counter"]->content) == 1) { did it. Thanks No Sssweat, I really appreciate your help! Oct 20, 2017 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.