0

I have a requirement to create a view which will return the latest 4 articles added to the site to be displayed in a block on multiple pages.

This in itself is easily done - however the client has requested the ability to override the articles shown in this block on certain pages. Again this would be easy if all 4 latest articles were to be swapped for these 4 statically selected articles - but the request is to allow any number between 1-4 static choices to be made when creating content.

If a user chooses just one article manually - the other 3 in the "related" block should be the latest 3 articles from the site. Similary if 2 were manually selected, 2 latest articles should follow them. And so on.

I think I may be overcomplicating this - but having played with Views all morning trying to achieve this I'm struggling - can anyone give me some pointers?

4
  • What do you mean 'statically selected articles' from (2nd para) and 'manually selected' (3rd paragraph). may be I'm missing something here. Sep 10, 2014 at 11:39
  • Sorry I wasn't clear. When creating some pages the user can select (via a node selector) certain 'related' articles that should be featured on that page. If these are specified they take the place of one or more of the automatically defined "latest" articles. Does that make it clearer?
    – steve
    Sep 10, 2014 at 11:54
  • Couldn't it be 2 separated blocks that look like one? One who display the n related articles and the second that display 4-n latest articles.
    – Djouuuuh
    Sep 10, 2014 at 12:06
  • That could be a partial work around but the requirement is to show only 4 items in total.
    – steve
    Sep 10, 2014 at 12:18

1 Answer 1

0

This is possible with attached displays. You would create a view with 2 displays: manual and reverse chronological.

Manual would use a relationship with node's field (entityreference field) that allows to pick releated nodes.

Automated will always select 4 recent articles.

Attach manual to an automated to appear at the top.

You gonna end up with 4 to 8 articles.

To remove extra nodes from results, implement hook_views_post_execute()

1
  • Thanks so much for this response - I didn't get a notification for some reason so just trying this now. Will post back / accept asap :)
    – steve
    Oct 8, 2014 at 21:19

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.