Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - Modules
#11

[eluser]wiredesignz[/eluser]
Most of the code you see above is redundant now but will still work (to a point)

I am using a new Base_Controller class nowadays.
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Base Controller
*
* All page controllers extend this class
*/
class Base_Controller extends Controller
{
    public $data;
    public $autoload = array(
        'config' => array('application'),
        'module' => array('search'),
    );
    
    function __construct() {
        parent::__construct();
        $this->data =& $this->load->_ci_cached_vars;
    }
    
    function _remap($action) {
        $this->data += $this->config->item('settings');  //application config is autoloaded
        $this->data['page_title'] = ucfirst(get_class($this));
        
        if (method_exists($this, $action)) {
            call_user_func_array(array(&$this, $action), array_slice($this->uri->segments, 2));
        } else {    
            modules::run('error/error404', $this->data['page_title']);
        }
        
        $this->output->final_output = parser::parse($this->data['layout']);
    }
}
/* End of file Base_Controller.php */
/* Location: ./application/libraries/Base_Controller.php */

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Home extends Base_Controller
{
    function Home() {
        parent::__construct();
        $this->load->model('vehicles_model');
    }
    
    function index() {
        $this->vehicles_model->findPaged("isonline = 1 AND featured = 'Yes'", NULL, 4);
        $this->load->vars(array(
            'content'     =>  parser::parse('home_content'),
            'title'       => 'Welcome to '.$this->data['company_name'],
        ));
    }

    function featured()    { /* modules::run('home/featured'); */
        $vehicle = $this->vehicles_model->iterate();
        return ($vehicle) ? parser::parse('hot_pick', $vehicle) : FALSE;
    }
}
/* End of file home.php */
/* Location: ./application/controllers/home.php */
#12

[eluser]wiredesignz[/eluser]
Continued from previous post...
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Showroom extends Base_Controller
{    
    function Showroom() {
        parent::__construct();
        $this->load->model('vehicles_model');
    }

    function index($page = 1) {
        
        $page = $this->input->get('page');
        $found = $this->search->run($page)/9;
        
        $this->load->vars(array(
            'content' => parser::parse('showroom_content', array('found' => $found, 'page' => $page)),
            'title' => 'Showroom'
        ));
    }

    function page($page = 1) {
        $this->index($page);
    }

    function browse() { /* modules::run('showroom/browse'); */
        $vehicle = $this->vehicles_model->iterate();
        return ($vehicle) ? parser::parse('hot_pick', $vehicle) : FALSE;
    }

    function detail($value = NULL)    {
        
        $value OR $value = $this->input->get('id');
        $this->vehicles_model->findBy("stockno = '{$value}'");
        
        $vehicle = $this->vehicles_model->iterate();
        $vehicle = modules::run('fuel_saver', $vehicle);
        
        $this->load->vars(array(
            'content' => parser::parse('detail_content', $vehicle),
            'title'   => $vehicle->year.' '.$vehicle->description.' - ',
        ));
    }
}
/* End of file showroom.php */
/* Location: ./application/controllers/showroom.php */
#13

[eluser]Mikle[/eluser]
Thanks wiredesignz! You rocks!




Theme © iAndrew 2016 - Forum software by © MyBB