Skip to content
cloudmanic edited this page Jan 5, 2013 · 4 revisions

Sometimes as developers we want to make sure our CMS always has some default blocks. This way we can preload content into our blocks database. Later on non-developer types can update these blocks but at least they start with some defaults we set as a developer.

With this feature when you load a CMS control panel page it checks to make sure all the blocks we declare are in fact in the database. If they do not exist we create then and load them with default content. If they exist we do not override the content. To load default blocks we use the following function.

CMS::load_default_blocks('./blocks.php');

We pass in a path to a file that stores the default blocks. This configuration file looks something like this.

<?php 

return array(
	'test-1' => 'Test #1',
	'test-2' => '',
	'test-3' => 'Test #3',
	'test-4' => 'Test #4',
	'test-5' => 'Test #5'
);

In the example each row is a block and a follow. For example "test-1" is the block name and the value would be "Test #1".

Typically we call this function just before the bootstrap function in our index.php Your index.php might look something like this.

<?php

require '../../vendor/autoload.php';

CMS::framework('laravel3', '../../application');
CMS::config_file('cms.php');
CMS::load_default_blocks('./blocks.php');
require CMS::boostrap('../../vendor');
Clone this wiki locally