0

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 1

3

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.

2
  • Yes, this worked for me! Thank you very much for Your time!
    – metalac
    Commented Apr 22, 2021 at 8:43
  • I'm glad to help :)
    – prkos
    Commented Apr 22, 2021 at 9:17

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.