0

I have a node type news with a taxonomy reference (news categories). And I have a view for the news. In this view I have a contextual filter by this categories. The category comes with the url.

In this view I need a rendered entity (node type "views header") within the view header. These node type also uses the taxonomy "news category". At this point all works fine.

BUT: for every news category I need another entity within the view header.

This approaches I have:

  1. Adding all nodes of type "views header" in the view header and filter them in the same context as the view itself. I tried if it is filtered per default with the view context filter but is does not.

The BUT here: I don't know how. How I can filter the nodes in view header. Is there a module for it which I didn't find?

  1. Publishing the view header nodes as blocks. Adding the blocks in views template and configure the block visibility settings pages/only the listed pages. This solution works but I think there's too much overhead.

Does anyone know a more elegant solution?

0

I can see a couple of ways ahead.

  1. Instead of creating a content type (a Node) just for the header, why not use the taxonomy term (an Entity) itself? Terms are fieldable, so you can add your additional content there, including image, other terms, &c. Then you can grab the term fields using the *replacement patterns from the "first row". You may need to create a Relationship to the term.

  2. If you really want another Node I think you could use the Views Field View module. This way you can create a second View on your "Views Header" type, returning only one result, and pass the term ID from the first View's header to your second View.

Note: Using Views Field View in this manner follows a pattern known as a representative view. IE: A View on a node that is representative of all other nodes using this term. Views 3 does actually support representative views natively though it has some limitations and is generally more difficult to use. I talk about it more over here.

  • I will give a try solution 2. That looks good. – deelite Aug 11 '15 at 14:05

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.