Welcome Guest, Not a member yet? Register   Sign In
[Solved] Need Help MY_Loader Custom Setup Query
#1

[eluser]riwakawd[/eluser]
I am trying to set up a custom MY_Loader.php file which will let me add this link in the public index $data['header'] = $this->load->controllers('common/header'); and any other I might like to add. The word "common" is the subdirectory.

I am trying to get it so can type it like so. I know it can be done but just do not know how.

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

class MY_Loader extends CI_Loader {

    public function controllers($subfolder, $filename) {
  $CI =& get_instance();
  APPPATH . 'controllers/'. $subfolder . $filename '.php';
}
}

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends MY_Controller {
public function __construct() {
       parent::__construct();
   }
public function index() {
  $data['header'] = $this->load->controllers('common/header'); //common is subfolder
  $data['footer'] = $this->load->controllers('common/footer'); //common is subfolder
  
  if (file_exists(APPPATH. 'views/theme/' . $this->config->item('config_template') . '/templates/common/home.tpl')) {            
   $template  = $this->config->item('config_template') . '/templates/common/home.tpl';            
  } else {
   $template  =  'default/templates/common/home.tpl'; // Fall Back
  }              
         $data = array('theme' => $this->config->item('config_template'));
         return $this->smarty->view($template, $data);
}
}
#2

[eluser]Tpojka[/eluser]
I am not sure if this can serve your goal, but this class allows you make subfolders in controllers folder.
#3

[eluser]riwakawd[/eluser]
[quote author="Tpojka" date="1397341254"]I am not sure if this can serve your goal, but this class allows you make subfolders in controllers folder.[/quote]

How would you make it work to be able to get what I am after. I do not want to use HMVC.

Trying to make it load like opencart. That's why making custom loader.

I am using codeigniter and smarty.
#4

[eluser]Tpojka[/eluser]
Since you are limited with way of making it (I.E. not wanting to use HMVC), I am afraid there is no much options that MVC supports.
Check these Q&A:
1. click1,
2. click2.
#5

[eluser]Tim Brownlaw[/eluser]
[quote author="riwakawd" date="1397358752"]How would you make it work to be able to get what I am after. I do not want to use HMVC.

Trying to make it load like opencart. That's why making custom loader.

I am using codeigniter and smarty.[/quote]

Opencart uses a HMVC structure... So I'm not sure why you are against using HMVC?
I looked at doing your approach some time back and the logical step was HMVC as doing it the "other" way is just painful...

I think you are restricting your options for the wrong reasons!

Just my 2 cents worth on the subject!

Cheers




Theme © iAndrew 2016 - Forum software by © MyBB