0

I have a View of taxonomy terms. I use the Relationship: Content using Categoria Secciones to show, with Aggregation, the listing of the category terms, and next to it, the number of products in that category. That works perfectly. But this is the part where I am stuck: I want to add a contextual filter of Fabricante, so I can filter by another Taxonomy. I have previously, in other ocassions, used contextual filter with a Content View, but not in a Taxonomy View. I have tried to add another Relationship in my Taxonomy View: Content using Fabricante and use this relationship in a contextual filter of type Has taxonomy Term id but it doesn't work.

In summary, I want a listing of taxonomy related to a product (which works) and add the contextual filter of another taxonomy which is assigned to the same product (this is where I am stuck).

Here, if it is of help, the SQL, with the correct TID of the additional taxonomy term, which is 32619. The listing is empty, even if the product is assigned to that taxonomy term.

    SELECT taxonomy_term_data.tid AS tid, taxonomy_term_data_taxonomy_term_hierarchy.tid AS    taxonomy_term_data_taxonomy_term_hierarchy_tid, taxonomy_term_data.name AS taxonomy_term_data_name, taxonomy_term_data.vid AS taxonomy_term_data_vid, taxonomy_vocabulary.machine_name AS taxonomy_vocabulary_machine_name, field_fabricante_taxonomy_term_data.nid AS field_fabricante_taxonomy_term_data_nid, MIN(taxonomy_term_data.tid) AS tid_1, 'taxonomy_term' AS field_data_field_imagen_categoria_taxonomy_term_entity_type, COUNT(DISTINCT field_taxonomia_taxonomy_term_data.nid) AS field_taxonomia_taxonomy_term_data_nid
    FROM 
    {taxonomy_term_data} taxonomy_term_data
   LEFT JOIN {taxonomy_term_hierarchy} taxonomy_term_hierarchy ON     taxonomy_term_data.tid = taxonomy_term_hierarchy.tid
    LEFT JOIN {taxonomy_term_data} taxonomy_term_data_taxonomy_term_hierarchy ON taxonomy_term_hierarchy.parent =    taxonomy_term_data_taxonomy_term_hierarchy.tid
    LEFT JOIN {field_data_field_taxonomia} field_data_field_taxonomia ON taxonomy_term_data.tid = field_data_field_taxonomia.field_taxonomia_tid AND (field_data_field_taxonomia.entity_type = 'node' AND field_data_field_taxonomia.deleted = '0')
   LEFT JOIN {node} field_taxonomia_taxonomy_term_data ON field_data_field_taxonomia.entity_id = field_taxonomia_taxonomy_term_data.nid
   LEFT JOIN {field_data_field_fabricante} field_data_field_fabricante ON taxonomy_term_data.tid = field_data_field_fabricante.field_fabricante_tid AND (field_data_field_fabricante.entity_type = 'node' AND field_data_field_fabricante.deleted = '0')
   LEFT JOIN {node} field_fabricante_taxonomy_term_data ON field_data_field_fabricante.entity_id = field_fabricante_taxonomy_term_data.nid
   LEFT JOIN {taxonomy_vocabulary} taxonomy_vocabulary ON taxonomy_term_data.vid = taxonomy_vocabulary.vid
INNER JOIN {taxonomy_index} field_fabricante_taxonomy_term_data__taxonomy_index ON field_fabricante_taxonomy_term_data.nid = field_fabricante_taxonomy_term_data__taxonomy_index.nid
   LEFT JOIN {field_data_field_imagen_categoria} field_data_field_imagen_categoria ON taxonomy_term_data.tid = field_data_field_imagen_categoria.entity_id AND (field_data_field_imagen_categoria.entity_type = 'taxonomy_term' AND field_data_field_imagen_categoria.deleted = '0')
WHERE (( (field_fabricante_taxonomy_term_data__taxonomy_index.tid = '32619') )AND(( (taxonomy_vocabulary.machine_name IN  ('secciones')) )))
GROUP BY tid, taxonomy_term_data_taxonomy_term_hierarchy_tid, taxonomy_term_data_name, taxonomy_term_data_vid, taxonomy_vocabulary_machine_name, field_data_field_imagen_categoria_taxonomy_term_entity_type, field_fabricante_taxonomy_term_data_nid   
1

I have been able to completely solve it. Using a contextual filter, but somehow I had no the options listed in the first edit, so I needed to create the filter first, and then edit again, maybe because I was using a relationship (not very user intuitive, BTW). So here it is important to use the relationship and complete the values below (all outlined in red). Now it works perfectly, the taxonomy terms are listed with the grouped count of items, and filtered by a different taxonomy, with the content Producto joining both taxonomies.

enter image description here

0

All you have to do is click on your contextual filter, then scroll all the way down, click on the blue MORE button and checkmark allow multiple values.

enter image description here

Yeah, it's hidden, lol.

  • Thanks, but it does not work, this option only allows multiple values for a taxonomy, but this is not the problem, I am getting multiple taxonomies, each with a value. It is an entirely different problem. I am still stuck. – Cesar Sep 14 '15 at 6:16
  • I agree. It was changed after the original title by someone else. – Cesar Sep 14 '15 at 8:37
  • it might be helpful if you can post a picture/diagram of what you're trying to accomplish. – No Sssweat Sep 14 '15 at 8:43
  • "I want a listing of taxonomy related to a product (which works)" If your view is listing the taxonomy related to the product. Lets say t-shirt and men are the tax terms. (ok so far so good) "and add the contextual filter of another taxonomy which is assigned to the same product" If this taxonomy is assigned to the product, shouldn't it be listed (on the first part of your quote) with t-shirt and men? – No Sssweat Sep 14 '15 at 8:49
  • 1
    No. I only wanted to list the first category. The second don't want it to be displayed, but it is a required filter. See my solution above. It now works perfectly. I simply did not use the relationship because the screen didn't let me to chose one. After editing the screen, now it appeared so I could complete the relationships. – Cesar Sep 14 '15 at 10:09
0

I have almost solved it, using a Filter instead of a contextual filter. I understand that I can call the view with Drupal API and set the filter to what I want... that would be similar to a contextual filter. I will try, though still not the most elegant way of solving it. I have tested it and works as I want, but I would like to have it as a contextual filter instead of just a filter. For some reason is not working there.

enter image description here

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.