CodeIgniter Forums
Community Auth and navigation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: Community Auth and navigation (/showthread.php?tid=64824)



Community Auth and navigation - AndrewDFrazier - 03-30-2016

I'm trying to use Community Auth on a new project - which is, I have to say, my first proper CodeIgneter project -  and I've got as far as being able to log in and log out which is great.

I've created a couple of views for various pages and I've split out my main navigation into separate views, also.

My problem now is that I want to have items on the navigation that visible dependant on the user level or role of the logged in user.  If I wrap a menu section in 

Code:
if( $this->require_group('group_name') ) {
// menu items here
}

the application errors with  

Code:
Call to undefined method CI_Loader::require_group()

How can I, therefore, restrict sections of my application and not have errors?  Do I need to create my navigation in a controller rather than a view?


RE: Community Auth and navigation - arma7x - 03-30-2016

Same problem http://forum.codeigniter.com/thread-64808-post-330663.html#pid330663


RE: Community Auth and navigation - skunkbad - 03-30-2016

(03-30-2016, 03:14 AM)AndrewDFrazier Wrote: I'm trying to use Community Auth on a new project - which is, I have to say, my first proper CodeIgneter project -  and I've got as far as being able to log in and log out which is great.

I've created a couple of views for various pages and I've split out my main navigation into separate views, also.

My problem now is that I want to have items on the navigation that visible dependant on the user level or role of the logged in user.  If I wrap a menu section in 

Code:
if( $this->require_group('group_name') ) {
// menu items here
}

the application errors with  

Code:
Call to undefined method CI_Loader::require_group()

How can I, therefore, restrict sections of my application and not have errors?  Do I need to create my navigation in a controller rather than a view?


Normally in views you are going to use the available authentication variables.

See: http://community-auth.com/documentation/usage/authentication-variables

Like this:


PHP Code:
<?php
if( in_array$auth_role, array('Admin','Manager','Supervisor') ) )
   // ... show a menu item ...