A PHP Error was encountered |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Template{ var $ci; function _construct(){ $this->ci =& get_instance(); } function load($loc,$tpl_name,$view,$data=null){ if($loc=='admin' && $tpl_name=='default') { $tpl_name = 'admin'; } if($loc=='public' && $tpl_name=='default'){ $tpl_name='public'; } $data['main']=$loc.'/'.$view; $this->ci->load->view('/templates/'.$tpl_name,$data); } } ================ Message: Trying to get property of non-object Filename: libraries/Template.php Line Number: 19 ============= <?php defined('BASEPATH') OR exit('No direct script access allowed'); class dashboard extends CI_Controller { public function index() { $this->template->load('admin','default','dashboard'); } } ================= Line: 10 Function: load ========== Can you help me to solve this problem ?
You're doing it wrong.
Have all of your controllers inherit from a custom controller which has the load function in it. PHP Code: <?php PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
Welcome Guest, Not a member yet? Register Sign In |