I am discovering one problem on my page - as a content I have some recipe. Under it, I've created a block which is displaying "Simular recipes". And now, this block is displaying some simular recipes AND the one which is in the content page above. So, I would like to ask if someone can help me how to do filtering to make this block not showing me the recipe which is in the page. Basically, need to block the node which I am currently in. Thanks in advance.
1 Answer
I'm assuming the Block you're using is a Views Block.
You can filter out the current node with the ID
Contextual filter (under Advanced
Views settings) from the "Content" Category with these settings:
When the filter value is NOT available
Provide default value
Content ID from URL
When the filter value IS in the URL or a default is provided
Specify validation criteria
Validator: Content
Content type recipe
Set the option for the case when the argument doesn't validate to something that makes sense to you.
More
Exclude
The last section of settings (More
) is where you have the Exclude option that makes the selection of the Contextual filter and reverses it, so it finds the ID of the current node, and excludes it from the list.
Test it by entering a node ID into the Preview field in Views, the node with the entered ID should be removed from the Views results.
You also need to select the Contextual option in the Block configuration or it won't work when you place the Block on pages, Views Preview can't test the Contextual works in actual placement.
-
Yes, this worked for me! Thank you very much for Your time!– metalacCommented Apr 22, 2021 at 8:43
-