1

I've got a content type (Brands) and a taxonomy vocab (Product Type) with a few options, so you can "tag" a brand with a specific product type. Using Views I'm filtering my content on my pages depending on the taxonomy term.

I've got a Views block (I'm also using this block as a dropdown in my navigation with the Menu Views module) that lists all the brands tagged with a specific taxonomy term. What I want now is that this block also shows up in my right sidebar on all the pages that display content of 'Brands' and are tagged with a specific term from my taxonomy vocab.

Example (menu structure):

* Product Type A
  - Brand 1 
  - Brand 2
  - Brand 3
* Product Type B
  - Brand 2
  - Brand 4
  - Brand 5

If I'm on the 'Brand 1'-page, the 'Brands' list under Product Type A should show up in my right sidebar.

I can't filter using the 'normal' way since its the same content type, and the same taxonony vocab. And by the 'normal' way I mean using a URL pattern for the content type and then use contenttype/* on my block config page.

Sidenote: I'm also adding a class to my <body> using hook_preprocess_html() for all the brand pages. So all the brands tagged with Product Type A have a class of product-type-a on their <body> field. Is there a way so show/hide blocks depending on a class through code?

Thanks.

0

You need to add two contextual filters to your view block:

Important: Use this block (override) for all these settings.

Content: Nid 

Provide default value: Content ID from URL

More:check: exclude.

This contextual filter will exclude Brand X from the list if you're visiting Brand X page.

Content: Has taxonomy term ID 

Provide default value: Taxonomy term ID from URL

check: Load default filter from node page, that's good for related taxonomy blocks.

When the filter value IS available or a default is provided:

Override title: Type here your block title using %1 for the first argument, %2 for the second, etc.

This contextual filter will list all your brands from current visited Product type

  • You're welcome. I'm glad I could help. – Jack-PL Aug 11 '13 at 15:22

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.