0

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.

enter image description here

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. enter image description here

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 :

enter image description here

What I want :

enter image description here

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.

2

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.

  • Is this working with alias ? – JudaPriest Oct 29 '14 at 14:34
  • Also it seems to solve the problem for the block display. But on Magazine/Book full mode, I will have to alter the link's render the article teaser to "[node_url/node_alias]/[argument]", isn't it ? – JudaPriest Oct 29 '14 at 14:39
  • 1
    Yes, exactly. Maybe it would be good to add "node/[nid]/argument" and you can create some automatic url alias on node create or node update. You can do that with rules, of course. – euphoricMV Nov 2 '14 at 16:21
  • I didn't manage to get it worked the way you told me, but it help to understand more my need and to find a solution. Thanks you :) – JudaPriest Jan 19 '15 at 7:37
-1

Sorry all, I had completely forgotten about this un-responded question.

It's been a long time so I don't remember the details. After a deep dive in custom and contrib', I managed to get it done with view_mode_page and context

At first view_mode_page didn't seems to respond to my need, but after more thorough tests, it do the job pretty smoothly.

  • In reference to euphoricMV post, it don't work with alias – JudaPriest May 19 '17 at 15:13

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.