0

I am having path aliases of the form

path/val1/val2/data

that are created with pathauto. I want to create a view that will be use a contextual filter and that will read only section 3 of the URL. When I set the view path to:

path/%/%/data

then I need to specify a contextual filter for section 3 (val2) that cannot filter my data properly.

My configuration looks like:

enter image description here Filter configuration:

enter image description here

So I need the CELEX content filter to match section 3 of the URL. Can I entirely skip %2 and just filter based on %3? Alternatively, can I declare the second section to be a wildcard in the view path?

When I attempt to Provide default value as Bryan Jones suggested, then it seems that default value doesn't work because the context filter actually DOES match the URL section, whereas the default value is provided when the filter value is NOT in the URL

What I see after previewing the view is

Context values: Context values

Query: (Notice the value that I wanted to be val2) Query

3 Answers 3

2

There is a specific contextual filter called "Global: Null" that you can employ to ignore a path part and leave the query unchanged. You will have to reorder the filters so that Null is in the right position (in your case, the first, since you want to ignore the first % of the path). See the screenshot:

The null filter

2
  • Yes! This is exactly what I was looking for! A /dev/null for context filters :)
    – Yannis P.
    Commented Feb 19, 2016 at 19:22
  • Thank you @peterpoe the Global: Null suggestion helped me out a lot.
    – LunkRat
    Commented Jul 7, 2021 at 21:59
2

you can use 'all' to get all values of 'val1'

Exp: path/all/val2/data

to get all values of 'val1', 'val2'

Exp: path/all/all/data

0

In the contextual filter you can select "Provide default value" From there you can select "Raw value from URL". You then choose the path component. enter image description here

I hope that helps!

7
  • please check my updated question, I think I had a typo too. I tried this solution before BUT the thing is that "Provide default value" is triggered when the filter value is NOT in the url. In my case the value value1 IS in the url but I want to avoid it and work with value2
    – Yannis P.
    Commented Feb 18, 2016 at 20:31
  • Provide default argument is triggered if the filter is in the URL as long as you select and option like "Raw value from URL" or "User ID from URL". Using "Raw value from URL" you can choose to only pull value2. Perhaps I'm not understanding. In the case of path/val1/val2/data you would choose path component 3. That should use val2 as the argument in which the view is filtered on. Commented Feb 18, 2016 at 20:50
  • Did that too, see edit, but still getting odd results. Could it be because the path uses pathalias?
    – Yannis P.
    Commented Feb 18, 2016 at 21:33
  • How odd. What happens if you try "path/val1/val2" in the preview? Commented Feb 18, 2016 at 21:40
  • Then I get path instead of val1 and the path value under the query is path/path/val1/data/val2 :P
    – Yannis P.
    Commented Feb 18, 2016 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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