[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 */