function PanelizerEntityDefault::render_entity in Panelizer 7.2
Same name and namespace in other branches
- 7.3 plugins/entity/PanelizerEntityDefault.class.php \PanelizerEntityDefault::render_entity()
Render the panels display for a given panelizer entity.
Parameters
stdClass $entity: A fully-loaded entity object controlled by panelizer.
array $args: Optional array of arguments to pass to the panels display.
string $address: An optional address to send to the renderer to use for addressable content.
Return value
array If the entity isn't panelized, this returns NULL. Otherwise, it returns an associative array as meant for use with CTools with the following keys:
- 'content': String containing the rendered panels display output.
- 'no_blocks': Boolean defining if the panels display wants to hide core blocks or not when being rendered.
Overrides PanelizerEntityInterface::render_entity
File
- plugins/
entity/ PanelizerEntityDefault.class.php, line 1559 - Base class for the Panelizer Entity plugin.
Class
- PanelizerEntityDefault
- Base class for the Panelizer Entity plugin.
Code
function render_entity($entity, $args = array(), $address = NULL) {
if (empty($entity->panelizer) || empty($entity->panelizer->display)) {
return FALSE;
}
list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity);
$panelizer = $entity->panelizer;
$display = $entity->panelizer->display;
$display->context = $this
->get_contexts($panelizer, $entity);
$display->args = $args;
$display->css_id = $panelizer->css_id;
// This means the IPE will use our cache which means it will get appropriate
// allowed content should it be selected.
$display->cache_key = implode(':', array(
'panelizer',
$this->entity_type,
$entity_id,
));
// Check to see if there is any CSS.
if (!empty($panelizer->css)) {
ctools_include('css');
$filename = ctools_css_retrieve($display->cache_key);
if (!$filename) {
$filename = ctools_css_store($display->cache_key, $panelizer->css);
}
drupal_add_css($filename, array(
'group' => CSS_THEME,
));
}
// We think this is handled as a page, so set the current page display.
panels_get_current_page_display($display);
ctools_include('plugins', 'panels');
$renderer = panels_get_renderer($panelizer->pipeline, $display);
$renderer->address = $address;
$info = array(
'content' => panels_render_display($display, $renderer),
'no_blocks' => !empty($panelizer->no_blocks),
);
return $info;
}