function esi_panels_url in ESI: Edge Side Includes 7.3
Build the URL to use for this ESI component.
Return value
string The internal URL. Generate a fully-qualified path by running through url().
2 calls to esi_panels_url()
- esi_panels_renderer_ipe::handle_esi_pane in modules/
esi_panels/ plugins/ display_renderers/ esi_panels_renderer_ipe.class.php - Replace a pane's rendered content with ESI content.
- esi_panels_renderer_standard::handle_esi_pane in modules/
esi_panels/ plugins/ display_renderers/ esi_panels_renderer_standard.class.php - Replace a pane's rendered content with ESI content.
File
- modules/
esi_panels/ esi_panels.module, line 201 - ESI handler for panel panes.
Code
function esi_panels_url($pane, $display) {
// ESI 6.x-1.x and 6.x-2.x used the URL patterns:
// Default: esi/panels_pane/theme:display_id:pane_id
// With context: esi/panels_pane/theme:display_id:pane_id/[base64($_GET['q'])]/task_name/context
// ESI 7.x-3.x uses the URL prefixes:
// Default: esi/panels_pane/theme:display_id:pane_id
// With context: esi/panels_pane/theme:display_id:pane_id/task_name
//
// All display arguments, and the original page URL (Base64-encoded) are
// appended to the URL prefix.
//
// Examples:
// - esi/panels_pane/bartik%3A4%3A9/page-page_user_test/1/dXNlci8xL215X3Rlc3Q%3D
// - esi/panels_pane/bartik%3A3%3A8/user_view/2/dXNlci8y
// - esi/panels_pane/bartik%3A3%3A8/user_view/1/dXNlci8x
$url = "esi/panels_pane/";
global $theme;
$url .= implode(':', array(
$theme,
!empty($pane->did) ? $pane->did : NULL,
$pane->pid,
));
// The did and pid are used to identify which pane content_type to load.
// Other available data to pass into the URL:
// - $display->args Are *always* passed.
// - $display->context A pane can only accept a single context.
// - $display->cache_key The cache key provides the name of the task/subtask.
if (!empty($pane->configuration['context'])) {
// If the context originates from the *TASK* plugin (which is typical), the
// task name is required in order to generate the task contexts
// ($base_context in panels_panel_context_render()).
// Additional contexts may be supplied directly by the display.
if ($task_name = _esi_panels__get_taskname($display->cache_key)) {
$url .= "/{$task_name}";
}
}
// Add all the display arguments to the end of the URL.
if ($display->args) {
foreach ($display->args as $arg) {
if (is_string($arg)) {
$url .= '/' . $arg;
}
}
}
// Add vid as an argument for panes requiring node revisions,
// such as workbench_display with Panelizer.
if ($pane->type == 'workbench_display' && isset($display->context['panelizer'])) {
$url .= '/' . $display->context['panelizer']->data->vid;
}
// Always add the current page URL.
$url .= '/' . base64_encode($_GET['q']);
// Set the CACHE mode.
$cache_mode = isset($pane->cache['settings']['override_context']['esi_overridden_context__user']) ? $pane->cache['settings']['override_context']['esi_overridden_context__user'] : DRUPAL_CACHE_GLOBAL;
switch ($cache_mode) {
case DRUPAL_CACHE_PER_ROLE:
$cache_string = 'ROLE';
break;
case DRUPAL_CACHE_PER_USER:
$cache_string = 'USER';
break;
case ESI_PANELS_CACHE_AUTHENTICATED:
$cache_string = 'AUTH';
break;
default:
$cache_string = 'PAGE';
}
$url .= '/CACHE=' . $cache_string;
// Allow other modules to alter the ESI URL (or respond to it).
// Pass in $pane and $display objects in an associative array for
// use as context. Clone objects to ensure they are not edited.
// @see hook_esi_block_url_alter().
$context = array(
'pane' => clone $pane,
'display' => clone $display,
);
drupal_alter('esi_panels_url', $url, $context);
return $url;
}