I am working on a project using the HMVC codeigniter. I have my own library for layout and this code My Base Controller with MY_Controller is:
class MY_Controller MX_Controller {public $ layout = 'layout_name'; Public $ theme = 'name'; ... public function __ composition () {origin: __ creation (); ...}}
My problem is: When I $ this-> CI = & amp; Get_instance ();
In the library, my controller's property such as $ theme
is unavailable. For example, $ this-> CI-> gt; & Gt; You can not use the subject
, but there is no problem with the controllers and I do not have the $ this-> Can use anywhere in the topic
How can I include my Base Controller variable in an example library?
solution According to, I use the second parameter to load the library and send my specified variable to the library through the array. In Mx_controller:
class extends MY_Controller MX_Controller {Private $ layout = 'default'; Private $ theme = 'white'; Private $ param = array (); Public function __ composition () {origin: __ creation (); $ This- & gt; Ultimate = array ('layout' =>> $ this-> layout, 'topic' => $ this-> subject); $ This- & gt; Load-> Library ('lib', $ this- & gt; ultimate); }}
No comments:
Post a Comment