How to load a codefight cms block in certain area?
Since i started to code my cms, i have learnt new things and ideas. My latest addition is blocks. I have created blocks of different parts, or say features. This one is currently working for template view files. Because of this, its quite easy to build a new theme for codefight cms.
If you check the file tree image you will get some idea. Or, for more detail you can download the cms. This is how blocks are loaded in the area you want:
$this->blocks->load('block_name');
or, you can even load a different blocks with one call using array as:
$this->blocks->load( array('block1','block2') );
When you create new theme, you may not need to edit new block, because you can use core block. But if you need custom block you can create one or copy core block and modify as required.
Like, for default theme, i didn't need to create a single block because i can use all blocks from core blocks. So i have only one file, index.php that is used to load blocks.
For 3columns theme, i needed just one block, page_view.php. The above blocks loader code gets core block. But in this theme we need to load page_view block from 3columns theme. So, how do we instruct loader to check the block in 3columns theme first?
This is how it is done:
$this->blocks->load('page_view', '3columns');
See below, what you can pass to a loader. first block filename, second template, and third extension of file. So you can load any file type with this loader. i.e. php, html, ..etc.
function load($filename, $template=false, $file_extension = '.php') {....}
Because of blocks its easy for me to load custom color adbrite code as well. This is how my adbrite block looks like:
//Set adbrite colors etc... $banner = array( 'sid' => '1072553', 'zs' => '3136305f363030', 'opid' => '1072553', 'afsid' => '1', 'size' => '160x600', 'provider' => 'adbrite', //'location' => 'header', 'AdBrite_Title_Color' => '666666', 'AdBrite_Text_Color' => '777777', 'AdBrite_Background_Color' => 'FFFFFF', 'AdBrite_Border_Color' => 'FFFFFF', 'AdBrite_URL_Color' => 'ffffff', 'show_your_add_here' => true ); echo $this->data_model->advertisement_get($banner);
This is helpful if you need to load adbrite advertisement with different color in different theme to match theme color. You can ofcourse use other advertisements too like google adsense, text link ads(TLA), etc.
If you have better ideas, i would like to know, so i can use it in next releases. Also, if anyone want to contribute themes, they are welcomed too. All the contributions will be honoured with contributors name and homepage link. Also would like to hear if anyone would use this cms in future, when it will be more powerful.
Thanks for all who supported.