![]() |
From view to controller. Moving logic from view to controller. - 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: From view to controller. Moving logic from view to controller. (/showthread.php?tid=56870) |
From view to controller. Moving logic from view to controller. - El Forum - 01-26-2013 [eluser]behnampmdg3[/eluser] Hey, I need to clean my disgusting view from php. Please give me tips. Thanks Code: <?php From view to controller. Moving logic from view to controller. - El Forum - 01-27-2013 [eluser]Aken[/eluser] First, if you have a block of commented code, just remove it. All it does is bloat the file. Your code isn't that awful, just has a lot of opening / closing PHP. I would iterate through your array in the controller first, and move the counter and base_url() logic there. Also, if your gallery link won't change, you can define it once instead of calling base_url() over and over (more a performance issue than how nice it looks). Also, base_url() accepts a string that's appended to the URL. It looks cleaner, IMO: Code: echo base_url() . 'images/events/' . $image['photo']; ?>_square.jpg |