![]() |
how to show parts of my view, if user does have access? - 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: how to show parts of my view, if user does have access? (/showthread.php?tid=33109) |
how to show parts of my view, if user does have access? - El Forum - 08-16-2010 [eluser]K.OS[/eluser] Hi, quick question, how would you approach this problem: I have one view, lets say a view called 'nav'. This view contains the complete menu structure for my site. I have some Users with different roles and not all of them are allowed to access all function through the menu. i blocked access for some controller functions with this function: Code: function requireUserRole($role = 3) only if this function call is true, certain other function will be executed… this works well to block access to functions in my controller. But because of the MVC structure i want to avoid calling this functions in my controller as well. How would you filter your view to show just some entries? Code: <ul> how to show parts of my view, if user does have access? - El Forum - 08-16-2010 [eluser]Clifford James[/eluser] Something like this? Code: <ul> how to show parts of my view, if user does have access? - El Forum - 08-16-2010 [eluser]K.OS[/eluser] but as far as i know you should not load a controller method in view?! correct me if I am wrong ![]() how to show parts of my view, if user does have access? - El Forum - 08-16-2010 [eluser]mddd[/eluser] You can put the 'user check' functions in a model (let's call it user_role_model). Then if you pass a reference to that model to the view like this: Code: $this->load->model('user_role_model'); Code: <? if ($user_roles->requireUserRole($user->role)) : ?> |