Views contextual filter if field value is X then show this in views page Y I have content type Ads.
I have multiple views pages.
I have Views which shows this content type Ads as a view block. Views has multiple block displays, each display for each views pages.


Admin need to choose when adding new node Ads where he want this ad to be shown. He need to choose it from the list. List has for example values X, C, Z

In the Views which shows these Ads as a view block. How to configure contextual filter to check field value? Contextual filter should be set on PHP code - but how to code it?

For example:


If field value is X -> show this view block on the path: categories/x (which is Views page, not node!)


** Solution **

I found my own solution to do something like this.


Added custom manual list field type (field_category). For example: X, Y and C
Add view block for each ad category and set filter field_category for each category. (field category = X)
Then in admin/block edit view block: Show block visibility, set PHP format and added this code:


&lt;?php
if (arg(0) == 'products' &amp;&amp; arg(1) == 'categoryX') {
return TRUE; }
else { return FALSE; }
?&gt;    

As my views pages path are: products/categoryX.
This sounds like a job for Page Manager (part of C-Tools).
Create variants that activate on content type AND field value.