Closed mali1991 closed 11 years ago
Hello there, you can create a BaseController and then extend it. For example: create a file with name base.php at your controllers like this: https://gist.github.com/scoumbourdis/6417186 Then just extend the Base_Controller instead of CI_Controller. In our case a simple example would be
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//This line code is required in order to work
require(APPPATH . 'controllers/base.php');
class Example extends Base_Controller {
Don't forget to add this line of code in order to make it work:
require(APPPATH . 'controllers/base.php');
as the above example.
What do you think about that?
well . That's a good idea . but cant we get any functionality in autoload file .Like we load session or grocery crud library in autoload file so we dont have to load it again and again or something like that.
Actually that's a very good idea. I've added an issue for that as a reminder: https://github.com/scoumbourdis/codeigniter-simplicity/issues/4 .
Thanks Johnny
Hello, any process on that yet?
Not yet :)
Hi there, i add one function to MY_output page. Then i called each controller this function. for front side and panel side used different sections. with this function i can send different data to template also.
function load_template($type = NULL){
$CI =& get_instance ();
$CI->load->library('menu');
if ($type == 'panel'){
$section = 'sections/panel';
}
if ($type == 'front'){
$section = 'sections/front';
$data["menu"] = $CI->menu->front_menu();
}
$this->set_template('panel');
$CI->load->section('head', $section.'/head');
$CI->load->section('nav', $section.'/nav',$data??"");
$CI->load->section('footer', $section.'/footer');
}
i can send dynamic menu items to template now.
Do i have to load the template in every controller .... or there is a way that default template is loaded automatically