Display node in multiple context I'm using Drupal 7, and this problem have been tormenting me these past few days :

let's say I'm using the basic content type Article, with basic view mode : full and teaser.



Now I'm creating a new content type Magazine, which reference multiple Article (with the module entity reference). On Magazine full view mode, I have set that every Article will be diplayed in teaser and linked to its content.


Easy isn't it ? Everything work fine. Noted that the red block in the sidebar are the same (with contexte module), and as the title.

Now I'm creating another new content type Book, which also reference multiple Article. On Book full view mode, Article are also displayed as teaser linked to  its content.
And now we have a problem when clicking on a Article from book: the sidebar and the title is from Magazine, and what I need is to display green block and title from Book. 

What I get :



What I want :



Is there a way to achieve that ? By contrib or Custom ?

P.S. An article can be referenced in Book, or in Magazine, or both, or neither of them.
You can add query string or another argument to the link of article, for example:

node/[nid]/magazine or node/[nid]?ct=magazine
node/[nid]/book or node/[nid]?ct=book


After that you need to add visibility to the Book and Magazine block that appears in sidebar.

For Book block:

node/*/book


For Magazine block:

node/*/magazine


Hope it will help.

P.S. You can add argument or query string to the link of article through template_preprocess_node function by changing $vars['node_url'].

P.P.S. Just figured out that you can only use new argument, not query string.