CodeIgniter Forums

Full Version: How do you manage navigation in your code / models / views
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I'm building an application where different users will have different menu items available to them depending on what they've paid for. There will also be multiple levels to the menu hierarchy.

What's the best approach to this problem?

I'm assuming I need a database table that represents the menu hierarchy, including the parent-child relationships of the nodes in the navigation as well as the sorting of the items. Then another table which I use to manage whether a user is authorized to access a particular item in that table.

When I render the view, I'd reference the menus, and the access rights of the user to output the menu, and I'd also need a function to check that same authorization from each controller in case a user manually types in a URL of a controller they're not supposed to have access to.

Is this the right approach? Any suggestions for caching this to prevent the constant look-ups of this type of info? I'm open to any suggestions on how you may have approached this type of requirement.