passing the same variables to all the views (to handle login status) |
[eluser]Unknown[/eluser]
Hi! I want to show in each page (almost each page) a login or logout link like the one in this forum. I'm organizing my views through django like inherited templates and I'm using dx_auth as authentication library. How I can accomplish that? I can for example pass each time a variable data["is_logged"] = True, though it leads to a big code duplication, what's the best solution you've found?
[eluser]nelson.wells[/eluser]
Create a "secure controller" that extends the base controller, and in the constructor do your if($logged){} check. Then, any controller in which all the methods need to be secured, you will inherit the secure controller instead of the base controller. Make sense?
[eluser]mah0001[/eluser]
http://davidwinter.me.uk/articles/2009/0...deigniter/ or google codeigniter MY_Controller
[eluser]mddd[/eluser]
You can 'give' variables to all views using $this->load->vars($array); Example: Code: // set variables |
Welcome Guest, Not a member yet? Register Sign In |