Support the ongoing development of Laravel.io →
Configuration Database Packages
Last updated 2 years ago.
0
Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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?

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.