Hi!

I'm using Authcache to cache pages and load blocks via ajax. That works for "normal" blocks that are positioned via the structure/blocks-page. But when I'm manually loading and rendering a (ajax enabled) block, I'm just receiving the complete content, so it is not loaded via ajax. Do I have to render it in a special way?

Comments

derMatze created an issue. See original summary.

znerol’s picture

You might get away with copying the relevant bits from authcache_block_page_alter().

Instead of manually rendering the block, I suggest to just introduce a new region into your theme. This way you only have to place the block into that special region.

derMatze’s picture

Using authcache_block_page_alter() as a base works! Thanks! :)

In my case the region-thing is not that easy, because the used blocks for a page are referenced via paragraphs module for every certain node...

derMatze’s picture

//edit: Solved

znerol’s picture

In this context, client refers to the personalization method (i.e. either ajax or esi).

derMatze’s picture

You're way to fast! ;-)
Problem was solved: AJAX just was not enabled for that block :/
Thanks!

znerol’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

firewaller’s picture

FYI for people who need a hand with this, here's some working code I'm using:

$block = block_load($module, $delta);
$block_array = _block_render_blocks(array($block));
$block_array = _block_get_renderable_array($block_array);

// Make custom block cacheable by Authcache.
// @see authcache_block_page_alter()
if (authcache_page_is_cacheable()) {
  foreach (element_children($block_array) as $key) {
    if (!empty($block_array[$key]['#block'])) {
      $block = $block_array[$key]['#block'];

      $block_id = "{$block->module}-{$block->delta}";
      $config = variable_get('authcache_block-' . $block_id);
      if (!empty($config['status'])) {
        $config += authcache_p13n_config_defaults();
        $fragment_id = 'block/' . $block_id;

        authcache_p13n_attach($block_array[$key], array(
          '#theme' => 'authcache_p13n_fragment',
          '#fragment' => $fragment_id,
          '#clients' => $config['clients'],
          '#fallback' => $config['fallback'],
        ));
      }
    }
  }
}

* Edited to place the authcache code in the correct part of the block array