Starter Templates
Regular starter template
This code is provided as the block template 'starter_template' with Blocks by AJAX. The code is copied here for easy reference.
<?php defined('C5_EXECUTE') or die("Access Denied."); /* Blocks by AJAX starter template. Simply insering the guts of an existing template where it says ORIGINAL BLOCK CONTENT HERE will serve to create an ajax template for most bocks. */ $c = Page::getCurrentPage(); $blkah = Loader::Helper('blocks_by_ajax','jl_blocks_by_ajax'); if($blkah->regular_block($bID) ) { if($c->isEditMode()) { echo $blkah->edit_mode_marker(); } /* ORIGINAL BLOCK CONTENT HERE */ } else { echo $blkah->ajax_loader($bID, $c->getCollectionID()); }
Package starter template
This code is provided as the block template 'package_starter_template' with Blocks by AJAX. The code is copied here for easy reference.
This template is intended for addon developers to use within a package, so it tests to see if Blocks by AJAX is installed.
<?php defined('C5_EXECUTE') or die("Access Denied."); /* Blocks by AJAX starter template FOR DEVELOPERS TO USE WHEN PACKAGING a Blocks by AJAX template with an addon block By John Liddiard (aka JohntheFish) www.legacy.c5magic.co.uk Simply insering the guts of an existing template where it says ORIGINAL BLOCK CONTENT HERE will serve to create an ajax template for most blocks. Blocks By AJAX is required. In edit mode, an error message is shown. In normal display, it is deliberately left to give a code error about the missing object/method. Seems like the bets way to get the editing user's attention. */ $rq_pkg = Package::getByHandle('jl_blocks_by_ajax'); $c = Page::getCurrentPage(); /* Blocks By AJAX is not installed - edit mode - leave a message */ if (empty($rq_pkg) && $c->isEditMode()){ ?> <div class="ccm-edit-mode-disabled-item"><div style="padding:8px 0px;"> <?php echo t('The \'Blocks by AJAX\' addon IS REQUIRED FOR THIS TEMPLATE TO WORK'); ?> </div></div> <?php /* Blocks By AJAX is installed, so */ } else { /* See note above about deliberately letting it give a php error */ $blkah = Loader::Helper('blocks_by_ajax','jl_blocks_by_ajax'); if($blkah->regular_block($bID) ) { if($c->isEditMode()) { echo $blkah->edit_mode_marker(); } else { /* ORIGINAL BLOCK CONTENT AND JAVASCRIPT HERE */ } } else { echo $blkah->ajax_loader($bID, $c->getCollectionID()); } }
Last updated: over a year ago