I have a panel with two panes, each containing a view. The panel receives an argument (which is actually a node id), which is sent to the views, where it is used as a contextual filter to select the right node. Now I would like the title of the node whose ID was passed as panel argument, to be used in the panel title.
Basically I want to what the node template wizard does. However, I do not want to override the node template, I want to create an additional one for the same node type. So is there a way to craete two different node templates for the same node type?
Comments
Comment #1
Letharion commentedI don't understand what you think will happen when you "Don't override the node template, but create an additional one".
If you want to control how the nodes are rendered, you use/override the node template. If you want different behaviour for different conditions in a single Page, you create variants with varying selection rules.
Please re-open the question if that does not help you.
Comment #2
freggy commentedI'm not sure where to find that option "Don't override the node template, but create an additional one".
I currently have already a panel overriding the default template for that node type. When I start the node template wizard, it asks which node type I want to create a template for, but the node type I want is not in that list (I guess because I already have one?). So I am not sure how to create an additional one with a different URL.
In the "Node template" panel, I see indeed that that template is a variant. I can clone that variant. But then I cannot set a custom path where that cloned variant should be available. Setting a path seems only possible for landing pages. But I don't know how to use a field in the title of the landing page then.
Comment #3
Letharion commentedI've never used the wizard, so I can't say how it works, but nothing prevents having two selection rules like
Node:bundle == 'page' && [Insert condition A]Node:bundle == 'page' && [Insert condition B]Sounds like you should just not use the wizard. On the other hand, it's not clear why you want to do that, as I doesn't quite make sense to me. If you want the title of the node to be page title, just set the title to %node:title and you're done.
Comment #4
freggy commentedCan you give me a walk through about how I should create such a page (via Structure - Pages, or Structure - Panels, and then...) or point me to some detailed documentation? Setting the title to %node:title does not work for a standard page, because it does not understand that this is actually a node template and the parameter should be interpreted as a node ID.
Comment #5
freggy commentedping?
Comment #6
Letharion commentedIf I understand correctly what you want, you should create several "Variants". Learn Page manager, specifically part 3, has a video that explains the concept.
I think it is rude to "ping" an issue.
Comment #7
merlinofchaos commentedIt's really hard to give you a walkthrough when your requirements are relatively vague. You need to be specific about what it is you want.
For example, one thing that's confusing is that you seem to want to display the node different depending an argument, and want it to be a different path; in which case, all you'd do is create a page with that path, wouldn't you? Clearly this is not what you want, though, or you would've gone and done that.
Comment #8
merlinofchaos commentedAlso, providing walk-throughs can be very time consuming. As volunteers, that's asking a lot. We can try to answer questions; the more specific, the better.
Comment #9
freggy commentedI will try to explain more clearly what I want to achieve:
I have a content type called "Researcher". It contains fields such as contact information, biography etc, but also a field which contains "research projects" (it's actually a "node reference" field, and can get multiple values).
I already have a panel defining a custom lay-out for the Researcher node type. It's defined under Structure - Panels and there under Manage Pages there is "Node template" where I have a variant Researcher. The summary for this page says that "when enabled, this overrides the default Drupal behavior for displaying nodes at node/%node" and it alsay says that it also works for aliases. That's precisely what I want for this first template, and it's working perfectly.
Now, because the list of projects by a researcher can get quite long, I do not display all these projects on the Researcher's page. I want to display them on a separate page. Furthermore you need to know that a project can be ongoing or finished. In the Research Project content type, there is a boolean field which determines whether a project is ongoing or finished.
On that new page which I want to create, I first want a list with header "Ongoing projects", and then a list with header "Finished projects" for a selected member (whose node ID is given as an argument). The path for this page should be /projects-by/ followed by the node-id as argument and the page title should be: "Research projects by [researcher-name]".
I created two content panes in the Views module: one which lists all ongoing projects and one which lists all finished projects for the given node id. So now I want to create a page with the panels module, which contains both Views, and sets the page title to "Research projects by [researcher-name]. Creating a page with the panels module which contains both views and passes the page argument to both views, is very easy with the panels module and I can configure it on the chosen path. This works fine, except for one thing: I cannot get the researcher's name in the page title field. That's very logical, because the panels module does not know that the page argument (which is being passed to both views), is actually a node id, so using %node:title does not work. That was my first attempt, which is the best result I could get as of now.
My second attempt was to create the said page as a variant in the "Node template" page in the panels module. In that case I can use %node:title, because it knows that the argument is actually a node ID. But then the problem is that I cannot configure the path: the "Node template" page, as explained in its summary, works on the URL's "node/%node" (and alias) path, which I already use for the template displaying the researcher's information (the first template I talked about in paragraph 3). So this second variant for the same node type, is actually inaccessible.
I hope now it's a bit more clear where I'm stuck.
Thank you all for your help and suggestions!
Comment #10
merlinofchaos commentedOk, I think I might have your solution...can the view be given the title you want because it knows the data? If so, then you can set the title type to 'From pane' and use the title of the view?
Failing that, is it possible to use a relationship to get a context for the node you need the title from?
Comment #11
freggy commentedThanks for your advice!
I don't think I can use the view title because the title of the two views is already "Current projects" and "Past projects".
Setting up a context sounds interesting, but it seems to work only for a specific node ID? At least when I choose Contexts - Node - Add context in the panel, I don't have the impression that I can specify that it should use the URL parameter for the node ID, but maybe I'm not correctly understanding this.
Comment #12
lsolesen commentedClosing old support questions. If this is still important to you, please reopen.