Help! How to set some general (global) vaiables? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Help! How to set some general (global) vaiables? (/showthread.php?tid=32892) Pages:
1
2
|
Help! How to set some general (global) vaiables? - El Forum - 08-09-2010 [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 Help! How to set some general (global) vaiables? - El Forum - 08-09-2010 [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. Help! How to set some general (global) vaiables? - El Forum - 08-09-2010 [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. Help! How to set some general (global) vaiables? - El Forum - 08-09-2010 [eluser]gyo[/eluser] Actually, for strict PHP5 you should also change the function MY_Controller to function __construct as mddd suggested. Help! How to set some general (global) vaiables? - El Forum - 08-10-2010 [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 |