How to pass taxonomy term from node context and to embedded view?

alaken's picture
public
group: Panels
alaken - Tue, 2008-06-17 23:43

First, thanks to Earl and Sam for Panels 2 - an amazing contribution to Drupal! I'm having a ball with it, but have hit a roadblock that has me stymied for the moment:

I want to make a panel page that takes a node id (or a path alias) as argument, and displays the content of that node in one pane, while extracting the top taxonomy term from the node, and passing the taxonomy term as an argument to some views panes in the same panel page.

Here's a diagram of what I mean:

Path: article/nid or article/path-alias

+----------------------------------------------+----------------------------+
|                                              |                            |
|Article headline                              | more in International      |
|                                              | (view filters on Business  |
| (term: Business) ------------------------------>  term)                   |
|                                              |  - link to article 1       |
| article body....                             |  - link to article 2       |
|                                              |  - link to article 3       |
|                                              |                            |
+----------------------------------------------+----------------------------+

Here's the steps I've tried:

- create a view that filters by a taxonomy argument
- make a panel pane from that view
- make a panel page (2-column)
- under Context/Arguments, add "Node ID"
- under Context/Relationships, add "Term from Node" and select the vocabulary I want
- under Content, in the left panel, add "Node Content" from "Node Context"
- under Content, in the right panel, add the view pane I want

What I can't figure out is how to pass the Term context into the embedded view so it filters properly. Can Panels 2 do this?

If anyone could help, it would break a major logjam I'm having on my site. Thanks in advance!


Your view should filter by

merlinofchaos's picture
merlinofchaos - Tue, 2008-06-17 23:56

Your view should filter by taxonomy tid.

Your panel pane for that view should be set to require a taxonomy term context for your view.

Otherwise, what you suggest should work.


Wow, that is just the piece

alaken's picture
alaken - Wed, 2008-06-18 02:27

Wow, that is just the piece I needed - terrific! Amazing fast answer that has made my week.

Here's a small follow-up: Before you gave me the key to this, I was trying by putting the term id as a path argument to the panel, not using any contexts, and just passing that argument to the embedded views.

The views were set to Default: "display all values", and the views pane argument source was set to: "from panel argument."

While this didn't let me override display of specific nodes (which you've solved for me,) it did one great thing: if the category argument was absent, the views panes would still display, unfiltered (which is what I want).

With this new context approach, if the context is not present (e.g. the displayed node has no terms,) those embedded views don't display at all (because I imagine the "required context" is, well, required :-) )

So the question: Is there any way to mimic the other behavior, i.e. if there's no term context, the embedded views can still display, just unfiltered?


I think I'm trying to do something similar ...

ulfk@drupal.org - Thu, 2008-08-14 08:57

I have a view that returns all nodes of type X, created by user Y (uid from argument).

I created a Views Pane for this view.

And then embedded that Views Pane in a Panels Page which has a url of events/%. This works great for users who have created nodes of type X. However I get a "Page not found" for users who have not created any nodes of type X.

I have tried:
- setting my argument default to all values (Display all values etc)
- adding additional custom content to the Panel Page so that some text is always shown/can be defaulted to
- giving the Panel Page a static title
- giving the Panel Page a title that uses the %user context

None of the above prevent the "Page not found" from displaying when the uid doesn't have any nodes of type X associated with it. Any one else encountered this? Is this intentional? Is there a workaround?