Posted by tobi20 on November 26, 2009 at 11:40am
Hi,
how can I print out a panel page with PHP? To be more precise, I have registered an url with hook_menu. My menu callback function should do nothing else but output a panel page as if the user directly entered the url of the panel.
For nodes this would be done with node_load and node_view. Any hints how this can be done for panels?
Thank you!
Comments
I'm exactly at same place...
Please, post here if you found a solution.
I'm exactly at this same place... so tomorrow I will start to review panels code to see how are called by the module preview or so.
Subscribing, I'd really like
Subscribing, I'd really like to be able to hand panels the arguments it needs after my module sorts them out first.
Half solved
Take a look at:
http://drupal.org/node/653584
http://drupal.org/node/685270
It's a partial solution, but take in consideration that we still don't know how to load correctly the panel if it includes a "view style" as viewscarousel, views_cycle and so on.
We tested it with panel-nodes and panel-pages but we didn't succed.
We finally fixed it in our project (based on OpenAtrium profile) dealing with templates, but looks like some page preprocess need to be done and is not.
I found it
Try to use page_manager_page_execute.
for example, I have "Custom" panel page with the name "page-home_domain_19", this code works for me:
<?php
module_load_include("inc", "page_manager", "plugins/tasks/page");
$subtask_id = "home_domain_19";
$output = page_manager_page_execute($subtask_id);
?>
Panels mini
If you are just wanting to render a panel in response to a URL, have a look at how panels_mini.module renders a panel as a block in panels_mini_block_view().
Drupal 7 - load and render mini-panel, with context
Drupal 7 - load and render mini-panel, with context:
<?php
$delta = 'my_mini_panel';
$panel_mini = panels_mini_load($delta);
ctools_include('context');
$context = ctools_context_create('entity:node', $node);
$contexts = ctools_context_match_required_contexts($panel_mini->requiredcontexts, array($context));
$panel_mini->context = $panel_mini->display->context = ctools_context_load_contexts($panel_mini, FALSE, $contexts);
$panel_mini->display->css_id = panels_mini_get_id($panel_mini->name);
// Here is the markup, to with with whatever you wish.
$markup = panels_render_display($panel_mini->display);
?>
For entities in general, this seems to be 'entity:ENTITY_TYPE'.
Thank you exactly what I
Thank you exactly what I needed. In my case I render a mini panel with a form so I send $markup to render() function to get the markup.
<?php
$delta = 'my_mini_panel';
$panel_mini = panels_mini_load($delta);
ctools_include('context');
$context = ctools_context_create('entity:node', $node);
$contexts = ctools_context_match_required_contexts($panel_mini->requiredcontexts, array($context));
$panel_mini->context = $panel_mini->display->context = ctools_context_load_contexts($panel_mini, FALSE, $contexts);
$panel_mini->display->css_id = panels_mini_get_id($panel_mini->name);
// Here is the markup, to with with whatever you wish.
$rendered_array = panels_render_display($panel_mini->display);
$markup = render($rendered_array);
?>
Best regards
David Park
Wunderkraut