Speed up pages and add interaction by loading blocks, stacks and areas by AJAX.
v2.0 - new remote control and trigger blocks!
v2.0 of Blocks by Ajax now includes an optional remote control block, making it easy to override default settings. See the documentation for details.
Rather than loading a block with the containing page, load the block later by AJAX.
Using blocks by AJAX is simple, just create a block as you normally would, then assign it a 'blocks_by_ajax' template. Loading the block will then start by AJAX after the page has loaded or in response to many configurable events.
For most regular blocks, its simply a matter of assigning a Blocks by AJAX template. Templates are included in Blocks by AJAX and Blocks by AJAX Templates1 for many popular core and addon blocks. Furthermore, many addon blocks also ship with a Blocks by AJAX template, so you can always ask an addon developer if their addon comes with a Blocks by AJAX template or they are planning one. An ongoing list of templates is maintained in the Blocks by AJAX Forum area
You can AJAX load other block types by:
Full details on creating a custom template for other block types are given in the support pages.
If you have Universal Content Puller, it can load stacks, areas from other pages and just about anywhere on the web with an included Blocks by AJAX template.
If not, you can also use a Blocks by AJAX template for the Stack Randomizer block. All you need to do is give it the 'blocks_by_ajax' template and a random choice of 1 stack will always show that stack by AJAX!
Blocks by AJAX includes templates for the Global Areas block and Parent Area block. To ajax load an area from another page, simply use one of these blocks with a 'blocks_by_ajax' template. A further addon, Universal Content Puller, includes its own template for Blocks By Ajax.
By default, the included 'blocks_by_ajax' templates will load a block as soon as its containing DOM becomes visible on the page. The Remote Control settings block or simple php options within the template can be used to start the AJAX load:
Remote Control settings can also be used to enable repeat loading of ajax content by any of these events.
If you find the block cache obstructs some uses of Blocks by AJAX, Cache Free Content provides Blocks By AJAX and Magic Data templates together with cache free clones of the core Content and HTML blocks.
From version 2.4 this addon is compatible with php7. To update a site to php7 you will need to make core updates (at time of writing only on github and not released). You will also need to ensure that other addon packages are php7 compatible.
See more addons by JohntheFish