Help! How to set some general (global) vaiables? |
[eluser]mddd[/eluser]
When declaring properties in your class you can only use static values. You can't declare a property to have a value that comes from a function. If you want to do that, you have to write: Code: class My_Controller extends Controller
[eluser]gyo[/eluser]
nope, victorche You just have to define your variable in the class properties, like: Code: class MY_Controller extends Controller Now, from every controller you'll be able to access $this->views without having to do anything.
[eluser]John_Betong[/eluser]
I think the information that can be stored immediately after declaring the class is limited. Once the variable exists then I store data from the controller. In the view it is called by $this->variable.
[eluser]gyo[/eluser]
Actually, for strict PHP5 you should also change the function MY_Controller to function __construct as mddd suggested.
[eluser]victorche[/eluser]
Thank you, @all! It works like a charm ... One last question I have ... Now I am not duplicating this part of code in every controller: Code: $links = $this->general->get_links(); Code: $data = array( Code: $this->template->set_partial('header', 'header_tpl', FALSE); // This is the header partial http://philsturgeon.co.uk/code/codeigniter-template |
Welcome Guest, Not a member yet? Register Sign In |