0

I have a content type which has taxonomy term field (Department). There is another field of the same taxonomy term (Priority Department)

I want to create a list of related content where the block shows only priority department related content and not the department field.

I tried views and contextual filter and relationship with no luck

http://oi65.tinypic.com/2z5kac3.jpg

Views config

Contextual config

  • Do you mean you want to show a list of nodes that are tagged with the same Priority Department as the node you're currently viewing? (Where the block is shown?) Is this field allowed only one term or unlimited? It should be straightforward to do in Views, it's about showing sibling nodes through Taxonomy, but don't use Has term ID Contextual, instead use the exact field Priority Department. Very similar question (you only have 1 CT), try to replicate the answer: drupal.stackexchange.com/questions/262218/… – prkos Sep 26 '18 at 22:00
  • What I looking for is a way to tag a node be separate from selecting what displays in related content block. So say a node can be tagged by the terms science and tech but I want to pull related content on this node by a 3rd tag called news and not the first two. How can I do that does it need to have a second field referencing the same taxonomy of department or do I need to create a duplicate taxonomy. Also when other node have selected Tech or News node 1 should be pulled in related content but not when they tag News. – nitnac23 Sep 27 '18 at 14:06
  • See image for more explaination i65.tinypic.com/2z5kac3.jpg – nitnac23 Sep 27 '18 at 14:28
0

You don't need to duplicate Taxonomy Vocabulary, one is enough.

You do need to have two Fields referencing the same Taxonomy Vocabulary, one for Department categorizing it, and the other for Select through which you're controlling what the related content is.

This is still a case of showing sibling nodes but through criteria of matching one field to a different field that just happens to references the same taxonomy.

  1. Create Views listing your Organization nodes in a Block Display
  2. Add Filter Select, set it to your vocabulary and then choose Is not empty (NOT NULL)
  3. Add a Contextual filter for the Field Department and configure it:
    When the filter value is NOT available
    Provide default value
    Taxonomy term ID from URL
    Load default filter from node page, that's good for related taxonomy blocks
    Filter to items that share any term When the filter value IS available or a default is provided
    Specify validation criteria
    Taxonomy term ID
    [your vocabulary]
    One or more IDs separated by , or +

  4. Place your block in a region shown only on Organizations, you will see nodes listed that are tagged with the term that is in the current node Select field.

This solution relies on the concept that you won't have the same terms in Select Field that you have in the Department field.

  • I tried this but just get a blank block no nodes being displayed. Also for some nodes there may be situation where the selection field terms and department field terms be same – nitnac23 Oct 1 '18 at 23:16
  • What happens when you enter Taxonomy term ID into Preview in VIews? Can you post your Views and Contextual filter configuration screenshots? The solution should still work if the terms are the same for the two fields. – prkos Oct 2 '18 at 0:04
  • Here is the view and contextual filter screenshots. They seem to pull some nodes but they are not correct. pasteboard.co/HGCiyzU.png pasteboard.co/HGCiS8V.png – nitnac23 Oct 2 '18 at 17:32
  • It seems correct at the first glance, but I see you have caching enabled. Can you turn that off, flush cache and see if it makes a difference. Caching should be enabled after you have it all working. Is the 197 a valid Taxonomy term ID? – prkos Oct 2 '18 at 18:02
  • I disabled the cache and tried again but shows the same result after flushing cache. I really appreciate all your help. Not sure what I am doing wrong. Yes 197 is one of the taxonomy term ID – nitnac23 Oct 2 '18 at 19:32

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.