0

I setup a view that displays published articles from a specific content type. I want to guarantee an article always displays, so I'd like to order the results to show the most recent post. That is easy enough to do using Filter Criteria and Sort Criteria in the View Block.

What I also want to do is if my authors decide to promote an article to the homepage, I'd like that article to get priority over the date sort criteria so that the article marked promote to homepage is the one that displays.

In the event that two or more articles are marked promoted to front page, I'd like the most recent article marked as promote to front page to be the one that appears.

I tried to create a new block in the same view that displays the most recent post and I tried to add that block entity to the No Results Behavior, but I am not sure if I was doing that right because it always showed blank. Was I on the right track by doing it that way?

Is there a way to do this in a view block in Drupal 8?

1

You are on the right track but, you don't have to create another view block. You can easily add more sort criteria on your existing view block and rearrange the sorting criteria. Also, just a suggestion it is better to use Sticky at top of lists than Promoted to front page. For more, you can refer to Frontpage views.

  • So it would something like sort by stick at top of lists and a sort by date? – Robbiegod Sep 5 at 18:30
  • Yes, Drupal will respect the sort criteria row weight. – Hunde Tekle Sep 5 at 18:33
  • oh ok, cool. I think where i was going was adding the promoted to front in the filter criteria then...Let me play around with it. Thank you! – Robbiegod Sep 5 at 18:39
  • That did the trick exactly. Thank you! – Robbiegod Sep 5 at 18:56

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.