Welcome Guest, Not a member yet? Register   Sign In
How to make custom helper work.
#14

[eluser]razerone[/eluser]
Thank for all your help to be able to load controller with in controller I had to do a couple of thing with all the information I have revived

I worked it out working will be posting download version on github https://github.com/Carrara-Website-Solutions

First Create I Application Path Core/ MY Loader File
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Loader extends CI_Loader{

public function __construct(){
  parent::__construct();
}

public function controller($file_name){
   $CI = & get_instance();$file_path = APPPATH.'controllers/'.$file_name.'.php';
   $object_name = $file_name;
   $class_name = ucfirst($file_name);if(file_exists($file_path)){
   require $file_path;

   $CI->$object_name = new $class_name();
   }
   else{
   show_error('Unable to load the requested controller class: '.$class_name);
   }
}
}
Second In Your Selected Controller

Controller Test1 Sample

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test1 extends CI_Controller {

public function __construct() {
            parent::__construct();
    
            $this->load->controller('test2');
       }

public function index(){
  $data['header'] = $this->test2->header();
  $this->load->view('default/template/common/home.tpl', $data);
}
}

Controller Test2 Sample

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test2 extends CI_Controller {

public function index(){}

public function header() {
  $this->load->view('default/template/common/header.tpl');
}
}

Now from Test1 you can echo out the controller in the view
View file <?php echo $header; ?>


Messages In This Thread
How to make custom helper work. - by El Forum - 01-19-2014, 07:22 AM
How to make custom helper work. - by El Forum - 01-19-2014, 08:41 AM
How to make custom helper work. - by El Forum - 01-19-2014, 08:53 AM
How to make custom helper work. - by El Forum - 01-19-2014, 10:26 AM
How to make custom helper work. - by El Forum - 01-19-2014, 10:08 PM
How to make custom helper work. - by El Forum - 01-20-2014, 02:37 AM
How to make custom helper work. - by El Forum - 01-20-2014, 02:58 AM
How to make custom helper work. - by El Forum - 01-20-2014, 03:22 AM
How to make custom helper work. - by El Forum - 01-20-2014, 03:38 AM
How to make custom helper work. - by El Forum - 01-20-2014, 03:55 AM
How to make custom helper work. - by El Forum - 01-20-2014, 04:13 AM
How to make custom helper work. - by El Forum - 01-20-2014, 05:44 AM
How to make custom helper work. - by El Forum - 01-20-2014, 06:21 AM
How to make custom helper work. - by El Forum - 01-20-2014, 08:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB