Closed (fixed)
Project:
Panels
Version:
6.x-3.x-dev
Component:
API
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
7 Dec 2009 at 18:08 UTC
Updated:
1 Jan 2012 at 15:15 UTC
Is there an API available for panels 3?
I would like to programmatically display a panel page through my own module.
thanks.
Comments
Comment #1
merlinofchaos commentedThere 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.
Comment #3
socialnicheguru commentedCould 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)?
Comment #4
mbria commentedSocialNicheGuru,
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:
As far as this show a kind of "raw" panel's panes:
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?
Comment #5
socialnicheguru commented@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?
Comment #6
merlinofchaos commentedYou should just use node_view($node) rather than trying to go directly to panels_node_view().
Comment #8
mbria commentedAs merlinofchaos says, this snippet works like a charm:
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.
Comment #9
mozart_ar commentedThanks! this work for me!
Comment #10
merlinofchaos commentedYou 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.
Comment #12
adunayevichg commentedI 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
Comment #13
Letharion commentedadunayevichg, 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.