0

Given the following Content Type: Smartphone

Taxonomy Vocabulary: OS: Android / iOS / Windows / Blackberry

Taxonomy Vocabulary: Color: Red / Blue / White / Black / Yellow

OS and Color is a Taxonomy Vocabulary which is term referenced in the content type smartphone.

Now the question is:

How do you setup a view to display only the COLORS that are available for the Android OS? I do not care about what phone it is. Example of this contextual path would be: example.com/android-colors

That in effect would just give me a list of all available colors that androids are in. Since OS and color has no direct relation, you would have to create a view of smartphones then GROUP THEM BY color while the contextual filter grabs the %android% arguement via the path.

The problem with this is that there will be thousands of records since each result is unique since your querying the smartphone table. Distinct setting in the query dialog box does not apply since each result is technically not distinct.

  • Couldn't you do example.com/%OS/%COLOR? The first taxonomy ID argument for OS and the second for color? – kyletaylored Feb 5 '14 at 6:11
  • no you cannot because you don't know which colors there are since OS and COLOR are not linked at all. The only thing matching these 2 taxonomy vocabularies is the content type "smartphone", but when you create a view to display the smartphones, you will get hundreds of results of smartphone colors. – Patoshi パトシ Feb 5 '14 at 16:24
  • If you have example.com/android, that will show all phones that are using Android. If you have example.com/android/blue, it wil show you all phones that are running Android and that are colored blue. That is how the terms are linked. Isn't that what you're looking for? – kyletaylored Feb 5 '14 at 17:44
  • no but i am looking for a list of colors that are available for android. how do you know there was a blue android in the first place when there isn't one!? just imagine a page with a list of colors that the android phones are available in and thats it... a list of colors. not a specific color. – Patoshi パトシ Feb 5 '14 at 19:46
  • I get it now, I think my answer will help. – kyletaylored Feb 5 '14 at 21:00
0

You can cheat a little and use Views Limit Grouping to help do this.

I created a view of smart phones with the path being smart-phones/%/colors. The only argument I need is for the OS. Add a contextual filter for the mobile OS using "Content: Has taxonomy term ID", filter by the term name. Under your fields to be shown, just select the color.

Using the Group Field (with Limit) formatter, we'll group by the color and show 0 items. Now if there are smart phones that have a color selected, it should show up in this list. In my screenshot you can see that I am only showing Blue and Orange, but in my taxonomy I actually have Blue, Green, Orange, and Red available - but I have no phones that are Red or Green.

From here, all you need to do is rewrite the color url to go to whatever other view you would like, such as smart-phones/%OS/%Color

Views Limit Grouping

Full View display

|improve this answer|||||

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.