Assume we have a Views page which does not have a contextual filter setting and the view path is /eureka. If you provide an argument in the url such as /eureka/abc, the argument is ignored and the Views page will return all view rows. But sometimes we may want to show the user a page not found instead of return all rows. This can be done by adding a Global: Null argument in the contextual filter.
1. Add a Global: Null input in the View Contextual Filters settings.
2. Check the Specify validation criteria option and select PHP Code as validator.
if (empty($argument)) { return TRUE; } else { return FALSE; }
Done =)
Hi, Thanks for this post, my site have the format url is domain/casinos, it will be return full list of casinos, but when I got some domain/casinos/aaa, or domain/casinos/bbb it still return a full list from the page, I found more result on drupal community but working incorrect. This page very useful and save a lot my time, thanks again.
LikeLike
You are welcome. =)
LikeLike
Thanks – just what I needed. Was driving me crazy trying to get a view to ONLY show results when the actual URL is not entered.
LikeLike
Good to know that i could help. =D
LikeLike
I applied it to my archive which has created year and month contexual filters.This is not working for me showing again blank screen
LikeLike