How call function in a view File - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: How call function in a view File (/showthread.php?tid=65332) |
How call function in a view File - nkhan - 05-31-2016 Hey , Guys. I have a function in Controller as follows: Path: controllers/category.php Code: public function get_category_name($parent_id=NULL) Now i want access that function product display page Path : view/products/index.php Code: $CI=&get_instance(); i have tried but the above code does not work , I am using Codeigniter 3.0.6. Please Me . Thanks RE: How call function in a view File - Diederik - 05-31-2016 You need to pass the variables with the desired content to the view instead of the other way around. You can have a look at the docs: http://www.codeigniter.com/user_guide/tutorial/static_pages.html RE: How call function in a view File - InsiteFX - 06-02-2016 You cam also create a CI helper file and add your code there then it is global to the whole app. RE: How call function in a view File - nkhan - 06-02-2016 (06-02-2016, 03:28 AM)@InsiteFX Wrote: Thanks RE: How call function in a view File - mwhitney - 06-02-2016 Additionally, if a function is only going to be used internally by your application, you don't want it to be a public method on a controller. Any public method in a controller is callable from the URL/browser unless you prefix the function name with an underscore. |