0

The following seems simple to me but i can't get it done in views:

A taxonomy vocabulary has two relevant fields: Name and Image. In the nodetype associated with this vocabulary i use Name as the linking field (i can not set the field up to directly use the image) but in the node view i want to show Image instead of Name. In my case Panels handles the display of my nodes. I turned to views and tried two alternatives with a taxonomyterm view and a content pane display:

  1. Add both vocabulary fields and rewrite the output from the Name field to use the Image field. If i put the Image field first i can see a replacement pattern that seems to match the Image field, but the result is crap. I think a real link between the node and the tax-terms is missing;

  2. I added a contextual filter with Taxonomy Term: Name but get stuck because the value is not in the URL. Everything i tried in options like "Provide default value" and "Specify Validation Criteria" fails. Also, using the Argument Input option in Pane Settings, picking Name from the node list under "from context" seems to do nothing. When i enter a valid Name value in Views Preview it returns the corresponding Image, exactly like i want. But someway that value isn't read when the view is run for real.

Any clues? Thanx in advance!

Kind regards, Cas

0

If I understand question aright, you need to use a Relationship in your View.

  • Under the Advanced section (just below contextual filters) click 'Add' to add a Relationship

  • Select the field in your node for the relevant term reference, e.g. a field labelled 'Tags' and with a machine name 'field_tags' would appear as Content: Tags (field_tags) in the list that is shown when you select 'Add'

  • The default configuration should be fine for the use case at hand, so in the next dialog box it should be OK to simply select 'Apply'. (In some cases you do want to tick Require this relationship.)

  • Go to Add fields and add a new field. Find the image field in your taxonomy. If the taxonomy is called Tags and the field labelled 'Image', it'll look like: Taxonomy term: Image Appears in: taxonomy_term:tags. Select this and click on 'Apply', Then click on 'Add and configure fields'

  • When you are in the configure dialog you'll see an indication that a relationship is being used. It'll look something like this:

enter image description here

  • Configure as required and apply. In your fields list it'll look something like this:

enter image description here

What these steps do is say that you want to use the field in the node that contains the taxonomy term to bridge to the fields in the particular taxonomy vocabulary item. Having added the relationship you can now add fields that call upon it. That, if I understand the question, is what is needed here. And, again, if I've understood aright, no need for contextual filters - at least not to get the image from the taxonomy into your view.

These steps apply to Views 7.x-3.5. (In pre 3.5 versions, or perhaps bit further back, the relationship set up was a bit more complex, but it's now more streamlined.)

  • Thanx a lot for your detailed explanation, Obliquely! I tried this and it works. Later i found a shortcut by using a relationship from within Panels so i don't need Views to get it done. Relations in Panels are added through the Contexts-section in the targeted variant. – caskraker Mar 5 '13 at 10:23
  • Great you found an alternative solution. Why not write up the steps for others as an answer to your own question and then mark your answer correct. I'm sure other drupal answers readers would appreciate it. – Obliquely Mar 5 '13 at 14:55

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.