2

I've tried all settings, with joint paths etc...but I just can't get the filter working properly, I know it's a settings thing, watched a whole bunch of videos but can't put my finger on it!

This is for advanced contextual filter, the dynamic one that can change depending on URL, not the static one.

Like this:

Animals
-Pets
-Farm

Path is:

localhost/animals/pets/cats.htm
localhost/animals/farm/cows.htm

I would like the filter animals/pets to show cats.htm content

I would like the filter animals/farm to show cow.htm content

I can get the filter working with single taxonomies, but not with full path.

animals works, but not animals/farm and not animals/pets

Attaching an image with the screen where I should set this up

enter image description here

4
  • Filter is dynamic, not the static one on left. It acts like a variable or a token, one in advanced settings. The .htm path is just for example sake Sep 10, 2017 at 16:13
  • A sceenshot of your complete view configuration would be helpful as well. Also, Drupal (and especially views) do not work with HTML pages, so how do you want to show cats.htm content? Sep 15, 2017 at 20:59
  • HTML is just for the example, not using .html suffix, that was just to distinguish the element as destination item, and not category name. Near giving up on this, I don't think it's even possible! Sep 15, 2017 at 23:25
  • You may implement HOOK_views_pre_view or HOOK_views_query_alter using your custom module to override the contextual filter with a custom value as you like. You can use something like arg(0) to read the URL. Sep 16, 2017 at 0:11

1 Answer 1

4
+25

You must use 2 contextual filters

enter image description here

First one is: Contextual filter: Content: Has taxonomy term ID depth modifier

enter image description here

Second one is: Contextual filter: Content: Has taxonomy term ID depth modifier with the same criteria you did.

enter image description here

I put the view path to be the vocabulary name and tested contextual filters like:

//Hierarichay
      tag1
        tag2
        tag2

//Urls
    tag1/tag2
    tag1/tag3

The views gets results for the child tags every time {2, 3}. If you didn't use the first filter it will consider the parent as argument.

Hope it solve your problem.

5
  • Thanks but now working still, what do I put for these settings? Depth Allow multiple values Set the breadcrumb for the term parents Display all results for the specified field Provide default value Show "Page not found" Display a summary Display contents of "No results found" Display "Access Denied" Skip default argument for view URL Sep 17, 2017 at 12:14
  • Display all results Sep 17, 2017 at 16:15
  • Thanks Mohammed, but not working...tried almost every possible settings and combinations, days trying now;( Sep 18, 2017 at 1:04
  • It depends on you site configurations, taxonomy terms hierarchy and content relations, more information it may help. Sep 18, 2017 at 5:52
  • Site for testing is over here: xuzo.com/a1test I sent you an email mohammed, whoever can figure this out will be my hero! Sep 21, 2017 at 9:08

Your Answer

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

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