No, not quite, doesn;t that package just add an active class?
I need lists of the navigation items available to maybe be stored in a database so that I can build navigations from them via the admin area. Think Wordpress and how that handles it's menus.
Well, I'm sure there're many approaches. Here's one that I can think of now.
Each modules provides a config that contains title. Your CMS loops through each modules and collect the titles. Of course, titles should be cached in a way. It really doesn't have to be a table. It can be a file as well.
moon0326 said:
Well, I'm sure there're many approaches. Here's one that I can think of now.
Each modules provides a config that contains title. Your CMS loops through each modules and collect the titles. Of course, titles should be cached in a way. It really doesn't have to be a table. It can be a file as well.
Great idea, I may look in to this one a little further, how would I go about looping through each module config and get the title?
You can simply loop through module directories and just get the config file (I know it's naive technique :) ) and cache those values. I'm sure there're many approaches, but that just popped up in my head.
If you plan to provide modules for a CMS, I assume you would provide an admin interface to disable/enable modules and a way to clear module configuration cache. Since the module configuration admin interface will not be user facing website, I would not worry about performance much.
Have each of your core modules fire an event that registers the module with the base application. You can then use the list of registered modules to determine what is installed or not.
You could even go further and register modules based on Auth logic, subdomain being used etc. Each module simply fires off an event in their boot/register method in the corresponding ServiceProvider and your MenuModule (or whatever you want to call it) listens for the responses to determine what other modules have been loaded.
Another option is a generic AppServiceProvider that contains an abstract class that your other service providers extend that could keep this logic in a single place so you don't have to repeat yourself.
abbajbryant said:
Have each of your core modules fire an event that registers the module with the base application. You can then use the list of registered modules to determine what is installed or not.
You could even go further and register modules based on Auth logic, subdomain being used etc. Each module simply fires off an event in their boot/register method in the corresponding ServiceProvider and your MenuModule (or whatever you want to call it) listens for the responses to determine what other modules have been loaded.
Another option is a generic AppServiceProvider that contains an abstract class that your other service providers extend that could keep this logic in a single place so you don't have to repeat yourself.
Perfect, this seems like a much better way of doing it! Thanks
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community