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

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

#12
[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');
}
}
?>

#13
[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.

#14
[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.

#15
[eluser]cPage[/eluser]
Thank you very much for the link


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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