Skip to content

Instantly share code, notes, and snippets.

@matglas
Created September 16, 2015 14:15
Show Gist options
  • Save matglas/290a4f683e38ecf708f2 to your computer and use it in GitHub Desktop.
Save matglas/290a4f683e38ecf708f2 to your computer and use it in GitHub Desktop.
Loading a panel with context programaticly
<?php
ctools_include('context');
ctools_include('content');
// Load ctools context from the arguments.
$context = array();
$context_arguments = array(
'identifier' => 'node', // Required: Identifier to the panel.
'name' => 'entity_id:node', // Required: Identifier used by argument plugins.
'title' => 'Node', // Optional.
'keyword' => 'node', // Required: Purpose?
'id' => '1' // Required: Needed for uniqueness.
);
$nid = $node->get('nid')->value();
$context = ctools_context_get_context_from_argument($context_arguments, $nid);
// Load the panel pane.
$type = 'slider';
$subtype = 'slider';
$conf = NULL;
$contexts = array('node' => $context);
$keywords = array();
$args = array();
$data = ctools_content_render($type, $subtype, $conf, $keywords, $args, $contexts);
print $data->content;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment