How To Use Negate options in contextual filter - Drupal views ?
In this blog, we are going to explain that how to show result with negate option in views i.e situation like "is not equal current nid" filter. Showing reverse result using Drupal Views need not required any additional modules, it's already an option 'Exclude' available in Views to achieve reverse result.
Lets see the following steps by which we can achieve the view result with condition like "is not equal current nid":---
- Create your view as your requirement.
- Expand the 'Advanced' options on the right side and Click 'Add' next to 'Contextual Filters'.
- Type 'nid' in the search box filtering the results to just 'Content: Nid' then check this box and click 'Apply (all displays)' button.
- Select "Provide default value" next to When the filter value is NOT available
- Select "PHP Code" next to Type
- Enter "return arg(1);" under PHP contextual filter code textarea.
- Now Expand the 'More' at the bottom.
- Check the box 'Exclude' and click 'Apply (all displays)' button.
- Now check view output, you will found the nodes list excluded the current node.