Is there an API available for panels 3?

I would like to programmatically display a panel page through my own module.

thanks.

Comments

merlinofchaos’s picture

Status: Active » Fixed

There is; it depends a lot on what you want to do.

Page Manager, for example, is very closely tied to the menu system. It's not easy to take what page manager provides and use it externally.

However, if you want to provide a UI to use the Panels layout editor and store this somewhere so that you can use it in your module, that's not too difficult at all. panels_node and panels_mini both basically do this. panels_node.module is a reasonably good guide for how to implement a UI that utilizes the layout editor.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

socialnicheguru’s picture

Could I use this to just render the panel:

function panels_node_view($node, $teaser = FALSE, $page = FALSE)

so if I want to print node 1, panels_node_view(1)?

mbria’s picture

SocialNicheGuru,

I tried your suggestion on 6.x.3.2 and looks like content is loaded but I missed myself on panels' API and I don't know how to apply the layout and render it.

Looks like panel_node is loaded correctly with:

      $node=node_load(19);    //my node with nid=19 is a node panel.
      $panel_node=panels_node_view($node, FALSE, FALSE);

As far as this show a kind of "raw" panel's panes:

      print($panel_node->content['body']['#value']);

but then, I don't know how to theme correctly as far as this just show the teaser: print (theme('node',$panel_node));

Any clue about how to follow?

socialnicheguru’s picture

Status: Closed (fixed) » Active

@mbria and @merlinofchaos,

Would we have to get $display in order to use panels_render_display to render the node?

Could we do something like this:

$display = panels_load_display($did);
print panels_render_display(&$display);

but how do I get the value for $did?

merlinofchaos’s picture

Status: Active » Fixed

You should just use node_view($node) rather than trying to go directly to panels_node_view().

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mbria’s picture

Status: Closed (fixed) » Active

As merlinofchaos says, this snippet works like a charm:

        $node = node_load(array('type' => 'panel', 'title' =>'Your Node Page Title'));
        $panel_node=node_view($node, FALSE, TRUE, FALSE);
        print($panel_node);

You only need to be careful building your page layout, as far as this snippet will only print the node_panel content.

The only problem I found it's that looks like loading the page by code is not compatible with some contributed modules.

For instance, I found problems with "viewscarousel" module that is unable to do it's job, probably because it's JS functions are not called on page OnLoad. I really don't know if this is the problem or I'm talking rubbish.

Any clue about how to fix this? Am I posting in the right place or I must ask viewscarousel people?

Thanks again for your help,

m.

mozart_ar’s picture

Thanks! this work for me!

merlinofchaos’s picture

Status: Active » Fixed

You should ask the views carousel people first. I can't think of a single reason why that should work any differently in that situation, unless you're doing something behind an AJAX barrier which can cause the js to not work.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

adunayevichg’s picture

Status: Closed (fixed) » Active

I have a similar question:

How can I render a panel (normal panel, not a node panel....) from a tpl.php routine?

and lets say I want to pass one parameter, a NID.

I would really appreciate any help.

Adolfo

Letharion’s picture

Status: Active » Closed (fixed)

adunayevichg, first, I'm just reseting this to closed fixed because so much time has passed, that I doubt this is still relevant to you.
Second, what you ask for is stated in #1 to be quite difficult to do, because page manager depends on the menu system.
If you still need this answered, you should probably open a separate issue, and explain what brought you to this strange solution, and we'll try to suggest something else that's easier to implement.