function esi_panels_renderer_standard::prepare_panes in ESI: Edge Side Includes 7.3
Prepare the list of panes to be rendered, accounting for visibility/access settings and rendering order.
This method represents the standard approach for determining the list of panes to be rendered that is compatible with all parts of the Panels architecture. It first applies visibility checks, then sorts panes into their proper rendering order, and returns the result as an array.
Inheriting classes should override this method if that renderer needs to regularly make additions to the set of panes that will be rendered.
Parameters
array $panes: An associative array of pane data (stdClass objects), keyed on pane id.
Return value
array An associative array of panes to be rendered, keyed on pane id and sorted into proper rendering order.
Overrides panels_renderer_standard::prepare_panes
File
- modules/
esi_panels/ plugins/ display_renderers/ esi_panels_renderer_standard.class.php, line 35 - Replacement for standard editor.
Class
- esi_panels_renderer_standard
- Extend the panels_renderer_standard class, to override render_layout(). The standard renderer renders the panes, then immediately renders the regions. We need to catch the panes after they're individually rendered, but before they're bundled…
Code
function prepare_panes($panes) {
// Override parent::prepare_panes, so that any access-controls are not
// applied to ESI panes. This ensures that panes are al
ctools_include('content');
// Use local variables as writing to them is very slightly faster
$first = $normal = $last = array();
// Prepare the list of panes to be rendered
foreach ($panes as $pid => $pane) {
if (empty($this->admin)) {
// @TODO remove in 7.x and ensure the upgrade path weeds out any stragglers; it's been long enough
$pane->shown = !empty($pane->shown);
// guarantee this field exists.
// If this pane is not displayed, skip out and do the next one.
// Do not handle user-access controls here for ESI panes (handle in the
// ESI rendering).
if (!$this
->pane_should_be_rendered($pane)) {
continue;
}
}
$content_type = ctools_get_content_type($pane->type);
// If this pane wants to render last, add it to the $last array. We allow
// this because some panes need to be rendered after other panes,
// primarily so they can do things like the leftovers of forms.
if (!empty($content_type['render last'])) {
$last[$pid] = $pane;
}
else {
if (!empty($content_type['render first'])) {
$first[$pid] = $pane;
}
else {
$normal[$pid] = $pane;
}
}
}
$this->prepared['panes'] = $first + $normal + $last;
return $this->prepared['panes'];
}