Welcome Guest, Not a member yet? Register   Sign In
Modulated Templated CMS system
#1

[eluser]Avatar[/eluser]
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://ellislab.com/forums/viewthread/60050/
also please see this thread for modules setup instructions:
http://ellislab.com/forums/viewthread/73177
configure your routes.php file like this:
Code:
$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:
Code:
<?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:
Code:
<?=$template?>


Messages In This Thread
Modulated Templated CMS system - by El Forum - 03-05-2008, 12:02 PM
Modulated Templated CMS system - by El Forum - 03-05-2008, 12:08 PM
Modulated Templated CMS system - by El Forum - 03-05-2008, 12:15 PM
Modulated Templated CMS system - by El Forum - 03-05-2008, 12:18 PM
Modulated Templated CMS system - by El Forum - 03-05-2008, 01:03 PM
Modulated Templated CMS system - by El Forum - 03-06-2008, 11:46 PM
Modulated Templated CMS system - by El Forum - 03-07-2008, 01:41 AM
Modulated Templated CMS system - by El Forum - 03-07-2008, 03:59 AM
Modulated Templated CMS system - by El Forum - 03-16-2008, 10:07 AM
Modulated Templated CMS system - by El Forum - 03-16-2008, 05:51 PM
Modulated Templated CMS system - by El Forum - 03-16-2008, 07:05 PM
Modulated Templated CMS system - by El Forum - 03-16-2008, 08:02 PM
Modulated Templated CMS system - by El Forum - 03-17-2008, 03:36 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 03:38 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 03:39 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 03:52 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 04:26 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 04:29 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 04:35 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 04:41 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 04:46 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 04:53 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 10:38 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 10:45 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 10:52 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 07:01 PM
Modulated Templated CMS system - by El Forum - 05-11-2008, 12:06 PM
Modulated Templated CMS system - by El Forum - 06-12-2008, 08:41 PM
Modulated Templated CMS system - by El Forum - 07-24-2009, 03:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB