Redundant data control in Controller, How!!! - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Redundant data control in Controller, How!!! (/showthread.php?tid=33460) |
Redundant data control in Controller, How!!! - El Forum - 08-26-2010 [eluser]Unknown[/eluser] I am new to CI, This is my code Code: <?php we can see each time maximum data remains the same, only 'view_contents_right' is different in each function. If i made a new function or any new controller i need to paste all the data again with update 'view_contents_right' data... Can we controller this redundant data.. Any link, or any thing that can help me... Thanks, Muhammad Ahmed Redundant data control in Controller, How!!! - El Forum - 08-26-2010 [eluser]Unknown[/eluser] Perhaps you can use attributs of your controlleur : Code: private $data = array('key1' => 'value1') Redundant data control in Controller, How!!! - El Forum - 08-27-2010 [eluser]Georgi Budinov[/eluser] If this redundant data is static and always pretty much the same it is better to move that to a config file. Then you can load the value and set the different pieces in it. Redundant data control in Controller, How!!! - El Forum - 08-28-2010 [eluser]InsiteFX[/eluser] Look in the CodeIgniter Users Guide MY_Controller InsiteFX Redundant data control in Controller, How!!! - El Forum - 08-28-2010 [eluser]Derdiusz[/eluser] You can also add an array variable to your controller: Code: class Home extends Controller { and in your constructor put your static data: Code: function __construct() { From now load view with: Code: $this->load->view('view_main', $this->data); You able to add (or replace) any data to your $this->data in other methods, like: Code: function about() { Greetings D. |