0

I have content types tagged from two different vocabularies (destination and category).

i.e. destination (main vocabulary, content must be tagged with of one of them)
- dest1
- dest2
- dest3
- dest4

category (content is tagged with at least 1 but could be more)
- cat1
-- subcat1.1
-- subcat1.2
- cat2
-- subcat2.1
-- subcat2.2

How can I create a view from these 2 different vocabularies?

i.e. dest1(term)/category(voc)/cat1(term)/subcat1.1(term)

  • if "dest1(term)/category(voc)/cat1(term)/subcat1.1(term)" is uri, with views this is not possible – svetlio Aug 26 '13 at 17:25
  • I probably don't explain myself correctly... What I want is that if I request to see contents that is tagged with a certain destination and also a category, I don't want to see contents tagged with any other terms in my view... should be easy enough to do but I just can't figure it out :( – sly-gdk Aug 26 '13 at 18:10
0

By default, Views Taxonomy page allows you to select multiple terms. If you click on the Contextual Filter "Content: Has taxonomy term ID (with depth)", one of the first choices you see is whether to allow multiple values.

Let's say that these categories have the following term IDs:

Destination Vocab:

  • dest1 [25],
  • dest2 [26],
  • dest3 [27],
  • dest4 [28]

Category Vocab:

  • cat1 [35] -- subcat1.1 [37] -- subcat1.2 [38]
  • cat2 [36] -- subcat2.1 [39] -- subcat2.2 [40]

If you want a page to show you all items in category 2 for destination 3, you'd have a url like this: http://www.example.com/taxonomy/term/27+36.

To limit the allowed Vocabularies, open that same Contextual Filter "Content: Has taxonomy term ID (with depth)" and scroll down to the section "WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED". There is a validation section where you can check off the vocabularies that you want included:

taxonomy validation http://www.emijayne.com/sites/default/files/linked/taxonomy.jpg

0

Unfortunately this does not seem to truly work. Maybe you CAN allow multiple values, but Drupal does not really DO anything with it, except for the first. In fact Drupal self says: "If selected, users can enter multiple values in the form of 1+2+3. Due to the number of JOINs it would require, AND will be treated as OR with this filter." In other words contextual filter does NOT filter down (reduce) with consecutive arguments. You don't get /destination/category1 OR /destination/category2 etc. You only get /destination/further-arguments-don't-matter. I am now trying some workaround by exposing the second filter, pre-selected for the value I actually would have liked Drupal to use as second argument. It's quite clumsy, because you have to make a view and build a path for each 2nd argument (categories in this case: say hotels, apartments, restaurants), but at least you avoid having to do it for the first argument (destinations: Sevilla, Madrid, Barcelona...) as well. Also I guess that means argument1 cannot have more than one (or a fixed number of) level(s) or else Drupal gets confused again.

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.