CodeIgniter Forums

Full Version: Frontend and Backend (Base controllers)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

El Forum

[eluser]Aken[/eluser]
I'm not going to watch a whole video tutorial series to figure out your point.

El Forum

[eluser]cPage[/eluser]
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 :


Code:
class Common
{
private $ci;

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

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


Anyway this code looks great for me :

Code:
<?php
class Admin extends Admin_Controller
{
function __construct()
{
  parent::__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']);
  $this->template->load($this->config->item('theme_url').'m_template');
}
}
?>

El Forum

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

Code:
class Common extends CI_Controller

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

El Forum

[eluser]xerobytez[/eluser]
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.

http://philsturgeon.co.uk/blog/2010/02/C...ing-it-DRY

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

Good luck with your project.

El Forum

[eluser]cPage[/eluser]
Thank you very much for the link
Pages: 1 2