I do load a panel (node_view) in a ct modal window. That works perfect so far. But now I need to load a specific variant of the panel.
I was playing with the handler stuff... but didn't get, yet.
How can I do this?
Here's my code for loading the panel programmactically:
function get_panel_view(&$node) {
// Load my task plugin
$task = page_manager_get_task('node_view');
// Load the node into a context.
ctools_include('context');
ctools_include('context-task-handler');
$contexts = ctools_context_handler_get_task_contexts($task, '', array($node));
$output = ctools_context_handler_render($task, '', $contexts, array($node->nid));
if ($output !== FALSE) {
return $output;
//return drupal_render($output['content']);
}
// Otherwise, fall back.
return drupal_render(node_view(node_load($node->nid)));
}
The function ctools_context_handler_render_handler()
does the trick, e.g.:
First you need to get all handler objects of the given panel, e.g.
$handlers = page_manager_load_sorted_handlers($task, '', TRUE);
Specify your handler (variant), which you want to display, e.g.
$handler = $handlers['node_view_panel_context_3'];
Now we got all needed arguments to fire the function:
$output = ctools_context_handler_render_handler($task,'',$handler, $contexts, array($node->nid));
And now, the $output
contains the variant (3) of my panel.