0

I am a bit stuck with this... I am not a drupal expert (yet :D) so I really don't know if I am using the best approach...

I have few nodes tagged with some terms from a vocabulary. Let's say my node 1 is tagged with term 1 and node 2 is tagged with terms 2 and 3. My vocabulary has, let's say, 5 terms in total.

Is there a way of getting in a view all the nodes NOT tagged with a particular term? This mean if I had a content node in a view tagged with term1 (node 1 in our example) I could get in another display of that view (or even in another different view) a list of the remaining terms not tagged (2, 3, 4 and 5 in my example).

I know I can make it using "static" filters, but I need to extract the information (terms tagged) from the node itself, which is loaded dynamically using contextual filters.

I am using panels as well but I am not sure wether that details are worth explaining for my porpoise.

I hope my question is clear enough as English is not my mother tongue.

Thanks in advance for your help.

  • Do you want the nodes in PHP or in a View ( views module )? – David Thomas May 7 '13 at 2:40
  • Just views David. :-) – José L. May 7 '13 at 14:12
0
  1. Create a new views page
  2. Select/Add the node related fields that you would like to refer while filtering the nodes.
  3. Add a filter to filter the nodes by content type
  4. Add a filter: Taxonomy term: Term
  5. Select: Expose this filter to visitors, to allow them to change it
  6. Select: 'Expose operators' and 'Reduce duplicates'
  7. Save the filter and view.
  8. Now go run the url of the views page.

You will see the filter at the top of node fields. 1. Select the filter as (Operator: Is none of) and select the term (Term 1) as per your eg. 2. Click apply button 3. You will see all the nodes which are not tagged to Term 1

  • Thanks for your answer AnAnD. As far as I can see, that expose the filter to visitors in one url. Is there a way to get something similar but using, for example, url arguments instead of that filter? I.e. www.myhost.com/viewpage/mytermid would return all the nodes of one content type not tagged with "mytermid". – José L. May 7 '13 at 14:19
  • In that case, Remove the exposed operator and by default keep the filter operator as "IS NONE OF". So that now only the terms are exposed and you can filter the nodes not linked with the selected term by selecting the term. – AnAnD May 8 '13 at 5:50
0

Finally I ended up width different approaches to this problem. The simplest one:

  1. Use a contextual filter in views.
  2. Use the option "Exclude" at the end of the form (under "More" tag). This way you can get all the nodes NOT tagged with the term passed to the contextual filter.

¡Hope this can help to someone else!

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.