-2

I want to make an intelligent view and want to pass contextual filter. If the contextual filter value is passed in the url so only display the article having the id like http://example.com/article/2. So show only the node with the id 2. And If the id not pass so(http://example.com/article/) show all the articles. I can do this by creating 2 views but I want all this in a single view

2

Goto admin/structure/views/add and add a view like below:

enter image description here

After adding view, go to view edit page and Under "ADVANCED", select "Contextual filters", and add "Content: Id". Under "WHEN THE FILTER VALUE IS NOT IN THE URL" check "Display all results for the specified field". In the same block, under "Exceptions", Exception value should be null. Check below image.

enter image description here

Now if you go to http://example.com/article you will see all the articles. And go to http://example.com/article/123 you will see related article.

  • Thanks Ajay I am really thank full to you. You are really a kind and humble person. God Bless you. – Fawad Ali Jun 15 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.