nova-framework / framework

Demo application using Nova - this is an extensive playground, use "app" repository for real applications.
http://novaframework.com/
MIT License
418 stars 210 forks source link

loading data in a theme's config file ? #2122

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello how to load the configuration information of a theme under nova 4.2?

I'm looking and can't find any information

LuckyCyborg commented 3 years ago

A Theme is just a type of local Package, like is also the Module.

As any Package, a theme has support for having own configuration files. To access those config items, you should use the package namespace, as defined into is ServiceProvider.

For example, to access the configuration items from the AdminLite theme, which have the namespace admin_lite you can do:

$customColor = Config::get('admin_lite::config.customColor', 'FFFFFF');

Please note the part before :: which is admin_lite because this is the namespace of this Package.

This assume that you put the config item into Config.php from Config directory. You may use other config files, for example for Colors.php you can use:

$customColor = Config::get('admin_lite::colors.customColor', 'FFFFFF');

Same logic applies to any Package, and also to the any local variant, be it Theme or Module.

ghost commented 3 years ago

Your explanation allowed me to overcome my problem which and certainly a lack of understanding !. I did not understand the system of the call via the namespace thanks to your example and rereading the lib config I finally understood clearly. if in the config: get () the custmColor value does not exist in color.php config then it takes the default value given as the second argument so 'FFFFFF'. problem solved Thank you

LuckyCyborg commented 3 years ago

Then, we could consider closed this issue.