help: get context from view?

Events happening in the community are now at Drupal community events on www.drupal.org.
brant's picture

Hello. I'm relatively new to Drupal and seeking some advice on working with Panels/contexts and a node reference relationship.

I have an Article content type that has a required node reference field, which points back to an Issue (thus an Issue has many Articles). I was happy to discover that using Panels module's Node template and context, I can apply a "template" to all my Issue items that passes the Issue node ID as an argument to a view/block that retrieves a list of the Issue's "child" Articles. Cool stuff.

However, we'd like the "Issues" section of the site to feature fields from the current issue (like title, cover image, etc.) as well as a list of links to that Issue's Articles. The "current issue" is determined by most recent publication date, and I already have a view/block that can find/display this. What I can't figure out how to do is to get the ID for the node returned by the current issue view out such that I could pass it as an argument to a view/block that fetches and displays the Articles. I'm using Panels for this display, and I feel like what I'm looking for is to add a Node context, but be able to specify a view rather than an explicit node ID when configuring it. I'm sure that's not quite the right thing, but hopefully helps illustrate what I'm trying to accomplish -- somehow getting that Issue node into context.

Is this sort of thing possible, or is there a better way to go about solving this problem? I know I could create a content type that would allow the admin to select the issue to display (and this give me the node context I need), but I don't want to create that maintenance point. I'm comfy hacking PHP if need be, but need some pointers on where to start.

Thanks in advance for any advice (and apologies to triDUG group for the cross-post)!

Comments

I would recommend creating a

merlinofchaos's picture

I would recommend creating a context plugin that runs the view but does not render it (just call $view->execute()) and then finds the nid in $view->result -- uses that nid to node_load() a node and then creates a node context.

You can them embed that context in the display.

It's on my wishlist to do this better.

Thank you very much for your

brant's picture

Thank you very much for your suggestion -- I'll dive in at some point to see if I can work that out. Sounds like what I was looking for.

In the meantime, I believe I've found a way to achieve what I was after using the Views Attach module, but it may have a few drawbacks (we'll see -- still poking at it).

Me too!

jensimmons's picture

I need to do this exact same thing. Thanks for this post and answer.... now I know it's not (yet) built into Panels, and I'm not just missing the right button.

Hmm....

I would love to see tool for this kind of thing in a future version of Panels :) Yummy.

Subscribing, having same

summit's picture

Subscribing, having same need.
greetings, Martijn

Panels

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: