1

This is my problem: I have 3 contextual filters, 2 Content : Has taxonomy term ID and 1 Content :Updated month

if I write in the url : test.com/International/North/06

It will show all the articles update the 06 in the International + North category

But if i write test.com/International/06 or International//06 to show just the articles update the 06 in the International category it doesn't work..

How can hide or set an empty condition on the second contextual filter to access on the third ?

0

contextual filters doesn't necessarily know when something is incorrect - it assumes the values are accurate and attempts to use them as you have it setup. You could do it this way:

  • create a custom views handler, or install Views PHP

assuming Views PHP:

  • for the second filter, provide a default php value that evaluates the url - if only two arguments are provided assume the second is missing and return all

Of course, this is quite presumptuous on the url information provided to Views, and will inevitably fail in some situations. Depending on how you link to the view and create the url, you are probably better off using a place-holder for the second value (international/--/06), with a similar default value set up as above whereby if the place-holder is found, it would return all

0

In my case I was wanting to programmatically render the view.

To make the second filter render all I had to use 'all'.

e.g.

views_embed_view('notes', 'display_mode', 'international','all','06')

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.