0

We have a page that needs to render an unspecified number of nodes, newest one first. The first result needs to be displayed as a very large "hero unit", the next 4 results as a group of four large results and the rest in a more compact form.

#########################
#                       #
#       Result 1        #
#                       #
#########################

############ ############
#          # #          #
# Result 2 # # Result 3 #
#          # #          #
############ ############

############ ############
#          # #          #
# Result 4 # # Result 5 #
#          # #          #
############ ############

Result 6      Result 7
Result 8      Result 9
Result 10     Result 11

I've been trying to style this by displaying the View as unformatted fields, but the nodes are still rendered separately from the structure, making it hard (or impossible?) to specify how we need them rendered.

Is there some module that will help us style the View with more precision or is there some feature in Views that I have overlooked?

1

You can do that by adding a "result counter field" (Global: View result counter) on your view. With this value you can edit your template file and build the conditions.

Hope that helps. Have a nice day.

2

You can do this in views with the pager offset option. Based on your example above, create a view like normal as a page or block then under the Pager set "Display a specified number of items" and set to 4 and then under the pager's options set offset to 1. This will skip the first item. Then add an attachment display to the view and attach it to your page or block before and set pager to "Display a specified number of items" and 1. Next add another attachment display and attach after and set "Display a specified number of items" to 6 and then under the pager's options set offset to 5. Now you override each display and output only the fields you need for each one.

  • Thanks for the great tip, I haven't used attachment views before, they seem rather useful. Time to find out more about them. I ended up using laebs' method, but this definitely seems like a more "Drupal" way of doing it. – Kaivosukeltaja Mar 27 '15 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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