Lullabot Ideas
We know stuff. We empower you to know stuff too.
Module Monday: Views Nodes Split
Article by Jeff EatonNovember 21, 2011 - 3:00pm
It's a simple request with a complicated solution: how can you display a list of nodes such that the first one is displayed in full, while the rest are displayed as teasers? For years, it's been possible to do that with the Views module by craftily combining two views: one for the first node, another for the remaining ones. While that approach gets points for craftiness, it's cumbersome and forces you to maintain two separate View displays. Thankfully, the newly-released Views Nodes Split module has made the trick simple.

Setting up the module is simple: just turn it on, and build your View as you normally would. Then, click on the View's Format option and select the newly available "Splited Content" row style. While the grammar is awkward, the results are great: you can specify separate build modes and display styles for the first node and all subsequent nodes from a simple config screen. In fact, you can even adjust where the cutoff happens: you might want the first three nodes to display in full, for example. No other changes are needed for your View; this module's new row style handles the rest.

Views Nodes Split is a great example of a simple module that does something useful, and does it well. If you've ever needed to build this sort of View for a front page, featured news, or other content listing, check it out!

Comments
Just wondering... how is this
Just wondering... how is this different or better than using a view of one full node with an attachment view of, say, three more nodes in teaser form? Just wondering if there's a particular situation or use case where this module would be a better choice than a view with an attachment.
Some benefits: you have only
Some benefits: you have only one view to maintain, only one query is used to get the results (besides the one for the pager) (and I think with attachment views, you execute two queries). Also, because the results are in the same view area, you have less html. You have also the same pager.
Probably, the most frequent case is when you want to render the first node different than the others, but you can also have for example the whole first page with nodes in full view, and the next ones only with node teasers. Of course there are many other solutions to this issue, but I think this one is really easy to use.
I guess we can do the same
I guess we can do the same with the display suite in views as well, correct me if I am wrong.
Perry.
Most probably yes. Using
Most probably yes. Using Drupal and its contributed modules, you can do the same thing in many different ways. If you want to use the display suite module to solve only this issue, I would say it is a bad idea... the module is just too complex to be used only for this particular issue. Then, I think there is a restriction if you want to use display suite in views: if you have a pager with more than 20 items per page, then you cannot select different view modes for your nodes.
Excellent.
This might be the straw that makes me to switch to D7 at last :)
...although it seems this wouldn't create the common layout of one full node followed by 2x2 grid of teasers – or am I missing something?
I think you can achieve that
I think you can achieve that with some css maybe... the module does not create any grid or custom layouts. It just renders the first X nodes in a view using a different view mode.
To do what you're after,
To do what you're after, create a 2 x 2 grid teaser view sorted however you prefer with offset of 1 so you skip the first record. Then create an attachment view limited to show 1 record with the same sort criteria. This solution is just using views without any additional modules. I'm pretty sure also that D6 will allow the same functionality but D7 is still worth switching for regardless. Views is so much better and more powerful...
Yeah, this is how I'd do it.
Yeah, this is how I'd do it. On the one hand, I get that this module is simpler in some ways--one query, less HTML. But on the other hand, it's adding a module to do something that Views can do. Which means another module in the mix when there doesn't have to be. I'm not sure I'd go down that road if I don't have to. But hey, there are lots of ways to do things well in Drupal.
Perspectives...
"But on the other hand, it's adding a module to do something that Views can do."
Well, the trick is that Views can't actually do this, at least not out of the box. There's no way to build a single view that executes a single query and displays the resulting nodes this way -- that requires a custom display style plugin like this one.
The "Attachment" approach is certainly doable using one less module, but it also results in more complex configuration on the administration side. Your preference probably depends on how frequently you need to use this particular pattern (One full node, many teasers) on your site...
Casque Monster Beats
Ce titre est issu d'un 33 tours que j'avais enregistre et mixe a Paris en 1977, au mythique studio HAUTEFEUILLE situe au 12 boulevard St Michel a Paris. Ce creuset a talents se trouvait dans une cave a l'Monster Beats aussi etonnante exceptionnelle, mais malheureusement disparu un dimanche matin sous les eaux de la Seine durant une crue plus severe qu'a l'ordinaire, nul n'est parfait... J'etais d'ailleurs assiste par Christophe Bertoux, Dr Dre Casque lui aussi parti trop tot. Ce morceau extrait du vinyle en question, a ete remasterise par mes soins. Ci-dessous, en cliquant au bon endroit et accompagne d'une pression correcte sur le bouton de la souris, Monster Beats savourer un titre complet de son album BLUEGRASS LONG DISTANCE : "Jonathan Cartland". Ce titre est issu d'un 33 tours que j'avais enregistre et mixe a Paris en 1977, au mythique studio HAUTEFEUILLE situe au 12 boulevard St Michel a Paris. Ce creuset a talents se trouvait dans une cave a l'acoustique aussi etonnante exceptionnelle, mais malheureusement disparu un dimanche matin sous les eaux de la Seine durant une crue plus severe qu'a l'ordinaire, nul n'est parfait...
You should implement this on
You should implement this on the Lullabot site, specifically the "Ideas" Views... http://www.lullabot.com/ideas
It's the perfect use case, because just like this article explained, the most recent content is displayed in a fancy format, but then repeated right underneath.
Not to criticize, but rather to suggest that it would add another reason to use this module.
Display an image for the first item in a Views news list
I want to create a view to display news like in this image:
http://i.stack.imgur.com/BQ05p.png
The list shows an image only for the first news, the other news only display the title.