You are here

function theme_authcache_p13n_fragment__authcache_ajax in Authenticated User Page Caching (Authcache) 7.2

Theme function for personalization fragment retrieved using an Ajax call.

File

modules/authcache_ajax/authcache_ajax.module, line 52
Inject personalized fragments into cached pages using Ajax calls.

Code

function theme_authcache_p13n_fragment__authcache_ajax($variables) {
  $url = $variables['url'];
  $fragment = $variables['fragment'];
  $param = $variables['param'];
  $attrs = $variables['attributes'];
  if ($url && $fragment) {
    drupal_add_js(drupal_get_path('module', 'authcache_p13n') . '/authcache_p13n.js');
    drupal_add_js(drupal_get_path('module', 'authcache_ajax') . '/authcache_ajax.js');
    $attrs['class'][] = 'authcache-ajax-frag';
    $attrs['data-p13n-frag'] = $fragment;
    if ($param) {
      $attrs['data-p13n-param'] = $param;
    }
    drupal_add_js(array(
      'authcacheP13nAjaxFragments' => array(
        $fragment => array(
          url($url['path'], $url['options']) => $param,
        ),
      ),
    ), 'setting');
    return '<span ' . drupal_attributes($attrs) . '></span>';
  }
}