luyadev / luya

LUYA is a scalable web framework and content management system with the goal to please developers, clients and users alike.
https://luya.io
MIT License
811 stars 205 forks source link

How I get config data in frontend? #2080

Closed testt23 closed 3 years ago

testt23 commented 3 years ago

Congratulations on still maintaining and upgrading this wonderful system for us! I have the following problem. In the administrative panel I create additional settings in the “Config” module: address, phone

I’m trying to get them in the frontend part like this: <? = Config :: get ('phone'); ?> however, the whole site “bugs” and gives an error. I need it so that I can correct it in case of a change of company address or company phone number. Since such options are missing in CMS Settings, I decided that it might be done through the Config module … but unfortunately it does not work.

Thanks for helping me.

LUYA Check ouput (run this script and post the result: luyacheck.php)

Additional infos

Q A
LUYA Version last
PHP Version 7.4
Platform Apache/XAMPP/MAMPP/etc.
Operating system Windows/Linux Server/OSX/etc.
nadar commented 3 years ago

Ensure you are using the correct model in the frontend: https://luya.io/api/luya-admin-models-Config (there are mulitple config models... sadly)

using Config::get('') definitely works, because we are using this often too. Ensure you are on the latest luya versions for cms and admin. if it still does not work you have to provide more informations like stack trace and screenshot.

nadar commented 3 years ago

and yes, the Config section in the admin area is definitely a good place for such global environment settings, and accessing those config with \luya\admin\models\Config::get('youridentifier') :+1:

testt23 commented 3 years ago

@nadar this is working correctly: <?= \luya\admin\models\Config::get('phone'); ?>

Thanks very much. I have add translate for Bulgarian users, review and approve them if you wish. :)

Thanks +1

nadar commented 3 years ago

sure, please send us a pull request :+1:

testt23 commented 3 years ago

I dont know, but I make a file in: https://github.com/luyadev/luya-module-admin/tree/master/src/messages /bg/ https://github.com/luyadev/luya-module-cms/tree/master/src/frontend/messages /bg/ https://github.com/luyadev/luya-module-cms/tree/master/src/admin/messages /bg/

but I dont see here? Wow :( ?