Here I will explain how to build a smarty templated modulated CMS.
please follow the instructions on this thread to setup your smarty templates system
http://codeigniter.com/forums/viewthread/60050/
also please see this thread for modules setup instructions:
http://codeigniter.com/forums/viewthread/73177
configure your routes.php file like this:
$route['default_controller'] = "default_controller";
$route['scaffolding_trigger'] = "";
$route['(.*)'] = 'default_controller/$1';
now create a controller called default_controller like so in your app/controllers directory:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Default_controller extends Controller
{
function Default_controller()
{
parent::Controller();
$this->load->library('smarty_parser');
$this->load->helper('modules');
$this->init();
}
var $method;
var $data=array();
function _remap($page, $content = '')
{
modules::load('search');
$data['page']=$page;
switch ($page)
{
case 'index':
case 'home':
$content = modules::run('home',$data,$this->method);
break;
case 'user':
$content = modules::run($page,'',$this->method);
break;
default:
//$content = modules::run('home');
show_404();
}
$this->render($content);
}
function init()
{
if($this->uri->segment(2)!='')
{
$this->method=$this->uri->segment(2);
}
else
{
$this->method='index';
}
}
function render($content)
{
$default_template = array(
'template'=> $content
);
/*default_layout only contains this string <?=$template?>*/
$this->smarty_parser->parse("ci:default_layout",$default_template);
}
}
now create a view inside you app/views directory called default_layout.php like so:
<?=$template?>
