2

I have two views called 'slider' and 'latest news'.

The slider view lists 5 nodes with content type news, article and blog post and if a custom field is selected on this nodes.

The latest news list the 5 latest nodes with content type news.

enter image description here

What I want to do is to exclude nodes from latest news view if they appear on the slider view.

If the slider view has only the news content type, it would be easy to exclude nodes by using the offset feature but because the slider view could have nodes from all these three content types and it's uncertain how many nodes come from each content type I couldn't solve my problem.

How to exclude nodes from latest news view if they appear on the slider view?

1

Try the Views Excluded Previous module:

The Views exclude previous module provides a views filter that excludes nodes that have already been loaded/displayed on the current page.

This is very useful when you have pages with several embedded views, and you want to make sure that a given node only appears once in the page.

2
  • Sorry, forgot to mention in my question: I have already seen this module but there isn't a stable version of this module so it scares me. Have you ever tried it? Thanks. – herci Jul 7 '16 at 20:20
  • I know of sites that use it in Production. Works great. – tenken Jul 7 '16 at 20:33
0

Step 1) Add a new boolean type field to your Article content type.

enter image description here

Step 2) Type Yes for on value, No for off value

enter image description here

Step 3) Checkmark ☑ Use field label instead of "On Value" as label

enter image description here

Step 4) Go to your Events and Blogpost content types and add the boolean field using existing fields.

enter image description here

Step 5) Edit the 5 nodes you want to see on the slider and ☑ checkmark show on slider.

enter image description here

Step 6) Go to your Slider View and add a filter of Show on slider, and select Yes.

enter image description here

Step 7) Go to your Latest News View and a filter of Show on slider, and select No.

enter image description here

Once you have all of this setup. You will need to print your views programmatically on the front page template using this technique: Multiple Views on a page - How to exclude already shown nodes?

5
  • Thanks for your answer. But it doesn't work for the case, unfortunately. Because I want to exclude nodes from the latest news view if only this nodes currently appear on the slider view. But if I exclude the nodes by using the custom field the latest news view disappear completely because almost on all the news content type the custom field is selected. What I want to do is to display the node in slider at first then when the time is up (5 more nodes come into the slider), display this node inside the latest news view. – herci Jul 8 '16 at 6:58
  • @herci updated my answer with pictures, hopefully it's clear to you now :) – No Sssweat Jul 10 '16 at 0:32
  • Thanks for the detailed answer but I think there is a misunderstanding here :). Because, in your answer the latest news view will not display the contents show on slider enabled. But, the Latest News views shouldn't care if "show on slider" is enabled or not, the only thing it should consider is if the content appears on the slider views right now. If so, don't show it on the Latest News views. For example there are 5 content on the slider and I added a new one. Then the oldest (6th) one will disappear from slider but not show on Latest News because "show on slider" is still enabled. – herci Aug 21 '16 at 5:12
  • 1
    @herci, understood. Seeing this Q again reminded of a nifty little trick. I will add a new answer soon, when I finish my project. – No Sssweat Aug 21 '16 at 6:59
  • @herci, I found it, the trick is here Multiple Views on a page - How to exclude already shown nodes? – No Sssweat Aug 25 '16 at 6:16

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.