Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 849
Sardorjon Vakkosov Avatar asked Nov 02 '12 11:11

Sardorjon Vakkosov


1 Answers

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.

like image 196
Boriana Ditcheva Avatar answered Sep 23 '22 02:09

Boriana Ditcheva