How can I set "is not equal current nid" filter in a view
Asked Answered
B

1

5

I have a content type named announcements and I am displaying a view block of latest announcements in a content which is belongs to announcements content type. This block has three fields: Taxonomy term, Title and link. I have put following filters:

1.Content: Type (= Announcements) 2.Content: Published (Yes)

The block is working correctly, but it is displaying current node fields too.

How can I not display current node fields in my view block?

thanks!

Bergstrom answered 2/11, 2012 at 11:10 Comment(0)
P
12

To make your block aware of what node it's being displayed on and to filter out fields that match that current node, you have to set up a 'Contextual filter'.... That includes settings to make your block aware of the current node, logged in user, etc.

  1. Add a Contextual filter (under the 'Advanced' section of the view)
  2. Select Content: Nid as the field you want to set up a contextual filter for
  3. Select 'Provide default value' = 'Content ID from URL'. This way the block will use as a filter the URL of the node it is appearing from when the filter is not found in the URL (and you won't really be using the URL to pass args, so it'll always default to this) enter image description here
  4. Now here's what's going to exclude those fields rather than display precisely them: in the collapsed 'More' section at the bottom of these settings is a checkbox 'Exclude'. Make sure you check that before saving the configurations.

That's it! Let us know if it works.

Propst answered 2/11, 2012 at 13:14 Comment(2)
I had did this many times as you said, but I forgot to check 'Exclude' checkbox . Now it is working perfectly. Thank you very much!Bergstrom
That's great! If you can mark that answer as 'accepted' by clicking on the check mark next to it, that would be even greater!!Propst

© 2022 - 2024 — McMap. All rights reserved.