1

I'm working with a page view that contains articles and a block view that contains tags. I would like to display all the articles tagged with the tag I click.

Tags page

So when clicking on the CITY tag I only want to display the articles tagged with CITY, does anyone know how I can achieve this?

Thanks

1

Give the page view a contextual filter for the taxonomy term field in question and click "Specify validation criteria", then choose the "Taxonomy term" validator, select your vocab, and select "Term name converted to Term ID" for the "Filter value type" setting, like this:

enter image description here

Then in your tags view, for your term name field, select "Output this field as a link" and set the "Link path" to be the path of your page view, with the term name on the end for the contextual filter, like so ([name] is the term name field in my case):

- Note that if this is a content view instead of a taxonomy term view you will have to add a relationship for your taxonomy term field before you can use the term name field. In your case the relationship should be "Content: Tags".

This would be the same for other entities, for example if your view was a user view and the user had the tags field on it.

enter image description here

Alternatively you could use the term ID contextual filter and term id field instead of using term name and the convert term name to term id option.

I prefer the term name as it looks nicer than term id in the url, but if you have really long term names or they have strange characters in them or anything the term id might be preferable.

| improve this answer | |
  • Thanks a bunch for your help but I think I don't fully understand everything yet. I could do the first part without problem. However I'm struggling with my tags views. My field in my tags view block is Content: Tags (which is the field I use in my article). How can I access the Taxonomy term field as I don't find it in my list when adding fields? Thanks – Yassin Tahtah Oct 23 '13 at 11:41
  • I updated the answer. Basically you have to add a relationship for your "Content: Tags" field first. – rooby Oct 23 '13 at 11:48
  • Oh yeah just figured it out! Thank you so much, just one more question, how can I get rid of all the duplicates? – Yassin Tahtah Oct 23 '13 at 11:50
  • That somewhat depends on why the duplicates are there as there are multiple reasons. The easiest thing to check is in the advanced column, in the "Query settings", you can check the "Distinct" option. This is not necessarily the best solution depending on the view though. If it doesn't help you maybe post a new question for it that also contains an export of your view. – rooby Oct 23 '13 at 12:00
  • Okay I think I got it working by messing around with the aggregation settings, thank you so much for your time and help – Yassin Tahtah Oct 23 '13 at 12:04

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.