![]() |
After running a method dinamically reload same page? - 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: After running a method dinamically reload same page? (/showthread.php?tid=27385) |
After running a method dinamically reload same page? - El Forum - 02-09-2010 [eluser]chefnelone[/eluser] hello I know this a simple task, but I can't figure it out how to do it. In a Controller called 'site' I have a method like: Code: function languagesBackend(){ In myPage.php view: Code: <a href="<? echo base_url();?>site/languagesBackend">English</a> Then, how do I do to reload myPage.php.? I need to do it dynamically since this link could be placed anywhere. thanks After running a method dinamically reload same page? - El Forum - 02-09-2010 [eluser]Sbioko[/eluser] First of all, you should get current page URL and simply refresh it using redirect. Read User Guide. After running a method dinamically reload same page? - El Forum - 08-17-2010 [eluser]tunesmith[/eluser] No, that doesn't work. current_url returns the url of the controller being called, not the url of the page it came from. redirect(current_url()) called from within a controller returns an infinite loop error. You want to instead run current_url in the previous controller, and pass it as a parameter to the second controller. Then redirect to that parameter. After running a method dinamically reload same page? - El Forum - 08-17-2010 [eluser]mddd[/eluser] I think urls should be linked to pages. Not to actions that don't have a page attached to them. In this case: what you want to do is perform some action and reload the page. Why not make it so that clicking the link submits a form to the page you are already on. The form could contain just a single POST variable. Like set_language = english. You could extend the Controller (make a MY_Controller) that checks in its constructor to see if $_POST['set_language'] is set. If so, run the 'languagesBackend' method. Then the controller will continue on as normal. This way it works in every controller. Alternatively you could put this functionality in a model and simply autoload it. |