![]() |
[solved] : controller functions calling from within fragment views, PHP4 -> PHP5 - 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: [solved] : controller functions calling from within fragment views, PHP4 -> PHP5 (/showthread.php?tid=3442) |
[solved] : controller functions calling from within fragment views, PHP4 -> PHP5 - El Forum - 10-02-2007 [eluser]tomcode[/eluser] Hi, I used to call functions defined in the controller from within my views. Under PHP4 this works without any problems. Now I'm switching to PHP5 and I get: Quote:Call to undefined method CI_Loader::insert_code() in my Controller I've defined the function : Code: function insert_code() in the fragment view I call it with: Code: <?=$this->insert_code();?> What to do ? I want to keep the function inside the controller (no helper or library loading) Thanks, Thomas [solved] : controller functions calling from within fragment views, PHP4 -> PHP5 - El Forum - 10-02-2007 [eluser]Matthew Pennell[/eluser] Return it as some data and then pass it to the view? Controller Code: $data['code'] = $this->insert_code(); View Code: <?= $code ?> [solved] : controller functions calling from within fragment views, PHP4 -> PHP5 - El Forum - 10-02-2007 [eluser]tomcode[/eluser] Sorry, did show my code example too simplictic. I'm passing information to the controller. Each view file contains different parameters, so I cannot set the values in the controller. The main idea is to keep the data out of the controller. Code: function insert_code($file = FALSE) And in the fragment views i have file 1 Code: <?=$this->insert_code('some_file_name');?> Code: <?=$this->insert_code('some_other_file_name');?> I also call the function several times per fragment view. [solved] : controller functions calling from within fragment views, PHP4 -> PHP5 - El Forum - 10-15-2007 [eluser]tomcode[/eluser] I found the solution. PHP5 Code: <?=$CI->insert_code('some_file_name');?> |