Updated the 'featured nodes' view for each book

I created a new block display in our frontpage_book_section view to display a more customized output.
Previously we had boxes with each ‘promoted’ node showing the title, teaser and ‘Read more’ link.

That worked fine in most cases but when we had a node with no teaser or body content those boxes were empty.
So I created a new block display that replicates the previous node output and also supports this ‘no teaser’ case.
When the view encounters a node without teaser content it displays all the ‘child links’ for that node instead. Which works great. The primary scenario where we have no teaser are ‘link pages’.
There are still cases where some users want to deliberately keep their featured boxes blank, even when there’s no content and in that case they can add an empty teaser to the body and the child links wont show up.

Here’s an example of the new featured boxes:
The current featured blocks don't have any blank cells

The bottom right box used to contain only the node title and left an empty impression on the user and now it’s displaying the child links.

Technical stuff:
That was done with Customfield: PHP code. I added some php to test for an empty teaser and call another view displaying the child links if need be.
Here’s the code:

node_revisions_teaser == ""){
  print views_embed_view('frontpage_book_section', 'attachment_1', $data->nid);

It works great.

Leave a Comment