Starter Templates

Permalink Browser Info Environment
Blocks by AJAX includes a standard starter template for those wishing to develop their own block templates. In most cases, creating a Blocks by AJAX template is as simple as inserting the original block view code where marked.
<?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


This starter template is included with the addon and is also attached here.

1 Attachment

Type: Discussion
Status: Archived
JohntheFish
View Replies:
JohntheFish replied on at Permalink Reply 1 Attachment
JohntheFish
For addon developers who would like to distribute a Blocks by AJAX template with the addon, the starter template also needs to test whether Blocks by AJAX is installed, as per the following package starter template.
<?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
*/
$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');

If Blocks by AJAX is not installed, 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 best way to get the editing user's attention).

From v1.1 this code is also included with the Blocks by AJAX package and is also attached here.

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.