1

I've been going through posts such as View block not accepting contextual filter argument, Contextual filter on Views Block file not found, How do I get a block to use a URL to configure a contextual filter?, Contextual filters help, Contextual filter with a block view and more to find the solution or my issue with no luck.

In short my contextual filter only works on 1 of 5 pages I want it to work on (they other 4 pages doesn't return any results). The working page is label/artists

I've got a taxonomy vocabulary called site_sections and an artist content-type. I've got a View Block of artist teasers, that I want to filter contextually by a part of the url alias.

I've got a term reference on each artist node to the site_section terms which are

  • label
  • publicity
  • shop
  • management
  • wholesale

My view is a block showing artist teasers. The block is displayed on these URL aliases:

  • label/artists
  • publicity/artists
  • shop/artists
  • management/artists
  • wholesale/artists

My contextual filter:

  1. Content: Site section (field_site_section)

WHEN THE FILTER VALUE IS NOT AVAILABLE

  1. Provide default value: Raw value from URL

  2. Path component: 1

  3. Use path alias: Y

WHEN THE FILTER VALUE IS AVAILABLE OR A DEFAULT IS PROVIDED

  1. Specify validation criteria: Taxonomy term (site section)

  2. Filter value type: Term name converted to term ID

  3. Transform dashes in URL to spaces in term name filter values: Y

  • 1
    Have you considered making 5 clones of the block and manually filtering them for the taxonomy for each site section? Or did you use taxonomy because you expect the site owner to add more sections? – Darvanen Sep 15 '14 at 0:40
  • Yes and yes:). But I'm the site owner so it might not be a disaster. I'm also about to get into the same challenge with a commerce product display. My main focus was to keep the site as clean as possible. You don't think it's possible to achieve via contextual filters? – Kristoffer Rom Sep 15 '14 at 0:43
  • 1
    And it might sound like a silly question, but I assume the spelling of your taxonomy and your paths are exactly the same including case (as shown in your question)? – Darvanen Sep 15 '14 at 0:47
  • It wasn't actually, the terms were written with 1st letter capitalized. It's changed now, ran drush cc all - still not working – Kristoffer Rom Sep 15 '14 at 0:53
  • 1
    Please disregard my previous comment as I did not take into account that it was a block view. I have duplicated your setup and I am getting the correct result, so your method is correct. There must be something small you are overlooking. – J. Reynolds Sep 15 '14 at 4:09
0

OK, found my error.

On the artist block configuration I'd copy pasted urls except for the label, it said:

`label/artists shop/artists/ management/artists/ wholesale/artists/ publicity/artists/`

Removing the trailing slashes did the trick.

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.