Welcome Guest, Not a member yet? Register   Sign In
Ho to build dynamic menus based on user roles/permissions
#1

I've been developing for long time on top of framework like Symfony2 and Laravel that I don't have a clue about what I will be asking and sounds like a dummy question for old developers but .... Sad

I am starting a new simple application and I will be using: IonAuth for authentication/authorization and I was thinking in KnpMenu for built dynamic menus (I am open to suggestion for this one since I don't know to much packages for CI just yet)

Since the menus should be based on roles/permission the idea is:
  • Start the application and goes to login page
  • Logged in successful
  • Query the database, find the proper items and built the menu
  • Redirect user to the homepage or dashboard

This "query the database, find the proper items and built the menu" should be the first code executed before every page load or maybe I should use another mechanism for just make this one time (after successful login) (again I am open to suggestion to this one as well).

So my question is, how would you handle this?
Reply
#2

I have a "navigation bar" library which performs the queries and organizes data the way I need to. Then I can call this library from anywhere
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#3

@albertleao "You have"? Can you share it so I can take a look and probably use it on my app?
Reply
#4

Unfortunately, I am legally obligated to say no. Sharing my companys code is a big no no.

What I can do is recommend that you write a simple library with a function such as getNavigation();

You can instantiate the library and pass in the user and create the nav from there.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#5

(07-28-2016, 06:07 PM)albertleao Wrote: Unfortunately, I am legally obligated to say no. Sharing my companys code is a big no no.

What I can do is recommend that you write a simple library with a function such as getNavigation();

You can instantiate the library and pass in the user and create the nav from there.

No problem, can you share at least a piece of code or an example in how to create and register a library? That's all I need to understand now since the "how to" is how I said and probably I will attach your answer as well
Reply
#6

Oooopppppssss nvm sorry for ask that I've found the docs and seems to be pretty good, I will come back if I need your help, for now thank you
Reply
#7

No problem.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB