• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Frontend and Backend (Base controllers)

I'm not going to watch a whole video tutorial series to figure out your point.

Quote:I don't know if you're confusing terminology, but you never want libraries to extend a controller class.

What do you think you do when you do this :

class Common
private $ci;

public function __construct()
   $this->ci =& get_instance();
} ....

/* Location: ./application/libraries/common.php */

Anyway this code looks great for me :

class Admin extends Admin_Controller
function __construct()

public function index()
  $this->data['header']['title'] = 'Administration';
  $this->data['nav']['active'] = 'administration';
  $this->data['content'] => $this->admin_model->dashboard($this->data['group']);
  $this->template->set('header', $this->config->item('theme_url').'header', $this->data['header']);
  $this->template->set('nav', $this->config->item('theme_url').'admin/nav', $this->data['nav']);
  $this->template->set('content', $this->config->item('theme_url').'admin/'.$this->data['group'], $this->data['content']);

I said you never want a library to extend a controller class. So considering I don't see anything like this:

class Common extends CI_Controller

That's not what's happening. I quoted your own words from your own post.

I think there was a mix up in terminology as well, when reading at first I got the same impression that Aken got which was you were trying to extend controllers from libraries which is no good obviously. Anyway, that autoload snippet doesn't help by loading base controllers from /libraries. I use a similar function when I want to have admin_controller or frontend_controller or whatever, this one is by Phil Sturgeon and is also placed in config.php. However it loads controllers from the /application/core directory which I think is better personally.


function __autoload($class)
if(strpos($class, 'CI_') !== 0)
  @include_once( APPPATH . 'core/'. $class . EXT );

Good luck with your project.

Thank you very much for the link

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.