Best way to display a node detail page with panels for my own content type?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
olav's picture

In case I want my detail page ($page=1) at /node/123 of my own content type to display in a panel - how would I do this?

One way would be to use a panel-page at /story, give it the NID as URL parameter and display the node on one of the panes. This, however, leaves /node/123 alone and makes it difficult to use pathauto.module to have nice URLs for nodes.

I thought of putting something like

<?php
define
('STORY_DISPLAY_ID', 42);

if (
$outer) {
 
$display = panels_load_display(STORY_DISPLAY_ID);
  echo
panels_render_display($display);
}
else {
 
// inner call in pane
 
echo '<h1>', $title, '</h1>', $body;
?>

into node.tpl.php. This would presumably get called twice, once for the whole page, once for the node content to be displayed in a pane.

A third approach would be to set the URL of a panel page to 'node', again passing it the NID as URL parameter. Would that work?

How would I set $outer to distinguish the two cases?

Thank you for any help.
Olav

Comments

Assuming Panels 2, do the

merlinofchaos's picture

Assuming Panels 2, do the following:

Set up your url, 'node/123'. (This'll keep pathauto working just fine). Make sure panels_page has a higher weight in the system table. (Note to self: Gotta fix that in the install/update script).

You'd do this basically without arguments, and use the more traditional URL sniffing methods of finding your content; both the 'node' and the 'view' content types support this at the moment.

By beta you'll be able to add the node object more directly and it'll be more flexible. I'm working on that piece Right Now, even, and alpha12 should allow you to just 'add node 123' to the panel, and get everything that entails.

Would like to have 'catch all'

olav's picture

Putting 'node/123' as URL for the panel page gives me node 123. However, I would like to have the panel page display all nodes (of a certain content type). Using 'node/%/panel' (as in the description of the URL field) works, e.g. node/123/panel and node/321/panel show the respective nodes.

Only, I would love to have just 'node/123' as URL, not 'node/123/panel'.

Using just 'node' as URL doesn't work either; this gives me the standard node display without using the panel page. I suspected increasing the module's weight in the system table might help, but it doesn't make a difference.

Sigh, I will probably have to debug the path handling to understand why node.module handles these URLs and not panel_page.module.

--
Olav

Do not despair!

merlinofchaos's picture

Do not despair!

1) update the panels_page.module to weight 10 in your system table.

2) Set up your panel to have the URL 'node/%' -- this is the trick to make it override.

3) Add the 'node id' argument on the advanced settings page. In its settings, check only the types you want overridden.

4) Add, at least, the 'node content', 'node comments' and 'node comment form' content types to your layout.

5) Bask!

No context

olav's picture

I had a deep look at panels_page_menu() and yes, learned from it that I have to use 'node/%'. When it tries to replace the '%' in the path it fails because ultimately in panels_context_create($type = 'node', $data = MY-NODE), panels_plugin_get_function('contexts', 'node', 'context') doesn't return a function to call.

I already have the Node ID argument configured (your 3). All content types are allowed (4). I had to look up 'bask' - hm!, I would love to.

Looking further, panels_get_plugins($plugin, $hook, $which) called from within panels_plugin_get_function('contexts', 'node', 'context') doesn't return an object. I am probably getting near...

--
Olav

That's a very new function

merlinofchaos's picture

That's a very new function -- so I'm going to assume you're running against current CVS -- when you cvs upped did you do cvs up -d? Because a new directory appeared, 'contexts' -- if you didn't get it, that could explain why panels_create_context() is failing for you.

That did it! THANK YOU

olav's picture

What a dump mistake. Although I am sure I did a '-d', Maybe I have just chosen the wrong moment to update. Thank you so much.

{{ On Friday at midnight they start to sell the German translation of the latest Harry Potter. I must definitely get my son into this 'merlin business' to have him avoid these kind of problems more easily. }}

--
Olav

Are you able to get to step

merlinofchaos's picture

Are you able to get to step 5, 'Bask', now?

/me drools

mlncn's picture

~ ben melançon

member, Agaric Design Collective
http://AgaricDesign.com - "Open Source Web Development"

benjamin, agaric

That works nice but ...

dmiric's picture

Hey all,

This is a rather old post but I thought I rather continue it coz my question is very related.

Merlin I did 1,2,3,4 and I basked for a while but ...

What I would like to do is to keep my url as for example:

www.example.com/conditions-treatments/allergies/food-allergies/overview

where:
"conditions-treatments" is vocabulary name
"allergies" is a parent term of "food-allergies"
and overview is the name of the node

I get this kind of url using pathauto module is it possible to do the same with Panel pages module

url as following is also acceptable:
www.example.com/conditions-treatments/allergies/food-allergies/PANEL/ove...

if /panel in necessary to separate taxonomy vocab and terms from a node title.

I'm alredy playing with this problem for 2 days so I think its time to ask for help.

Tnx

ah... thought I had this...

bobk's picture

same general problem as Olav.

I have a panel layout with two cols. Bottom left side is a
panel view of a list of cck nodes (title/teaser). The main panel
is aliased to "reviews".

Goal is that links in titles act within that content area.

Assumption was that I could create a cloned panel re-aliased
as "reviews/node/%", and set the context of the lower area to
display nodes, and then use path_auto to add "reviews" to
each node of that type... aka "reviews/node/27".

So...

If I use path_auto, links show up correctly, but take me to a normal
page view of the node (at "reviews/node/ID).

If I don't use path_auto, links are wrong, but if I correct manually, they
take me to the full node view within the paneled setting as desired.

I tried poking "10" into the system table for panels_page.module, with great
expectations, but to no avail...

There is probably a much easier way to do this, that I am missing.

Thanks for any insight.

Panels

Group organizers

Group notifications

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

Hot content this week