Where To Place View Related Function? |
[eluser]Md. Iftekharul Islam Sakib[/eluser]
Hi, I have some function in my project which are used to display Some Common Things Of View. As Example Code: function showTrueOrFalse($myBool) If I don’t use this function than I have to write the same code many times. For using these function I just call them from View. As Example Code: <?php showTrueOrFalse(true)?>; They will only be called from view. But as I have 3 views if I copy this function in both of them it will be a mere code duplication. I am new to codeigniter. I am not understanding where to put this view related functions. It will be very helpful if any of you help me.
[eluser]vrencianz[/eluser]
Create a helper in the <b>application/helpers</b> directory. See http://ellislab.com/codeigniter/user-gui...lpers.html for details. For example create <b>utils_helper.php</b> with the content Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); then call Code: $this->load->helper('utils'); from your controller.
[eluser]InsiteFX[/eluser]
How many forum topics are you going to ask this question in?
[eluser]Md. Iftekharul Islam Sakib[/eluser]
@vrencianz, Thank You Very Much. I have solved My Problem with using your advice. @InsiteFX, As it was my first, I created a topic wrongly in General discussion. Then I created The Topic in Code Section. I am very much sorry for creating multiple post. |
Welcome Guest, Not a member yet? Register Sign In |