How to change the Controller+Action if certain criteria met - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: How to change the Controller+Action if certain criteria met (/showthread.php?tid=1232) |
How to change the Controller+Action if certain criteria met - tom365 - 02-20-2015 I have a base controller, and in it I am loading the user model. If the model has some certain flags active, I want to change the action. e.g. User is visiting forum/thread means forum controller and thread action. But in the user model, the "is_locked" flag has value "1", so I want the CI to use the "account" controller and "locked" action, but I don't want the page to redirect to account/locked. RE: How to change the Controller+Action if certain criteria met - CroNiX - 02-22-2015 The only way to get to a different controller from one controller using native CI functionality is to redirect. RE: How to change the Controller+Action if certain criteria met - obiron - 02-24-2015 (02-20-2015, 04:00 PM)tom365 Wrote: I have a base controller, and in it I am loading the user model. If the model has some certain flags active, I want to change the action. By definition, what you have asked for is a redirect I infer that you want to carry out some action that is held in the account->locked() function; This may indicate that you do not have the separation of concerns correct between controllers and models. Can you showus the code that you are wanting to call in the other controller and we may be able to help you refactor it |