This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

thiago9438
thiago9438

Hello, i have created an model settings using SettingsModel inside a Plugin named "Core",

My question is: How can i register the variables of the model configuration to use in all pages from my theme ?, without having to create a component for example.

In this model, i put fields for my client definitions like, sitename, address, phone, emails, etc.. and i will get the values in my layout and pages..

Last updated

Tschallacka
Tschallacka

You can always store something in the config if some of your plugins get loaded?

 Config::set('site_settings', $site_settings);
 Config::get('site_settings');

Something like that?

Last updated

thiago9438
thiago9438

Tschallacka said:

You can always store something in the config if some of your plugins get loaded?

Config::set('site_settings', $site_settings);
Config::get('site_settings');

Something like that?

It works, but is it the most correct way?

Tschallacka
Tschallacka

Yes, it's better than superglobals. And you can simply disable it by removing your plugin. Also because a lot of namespaces are being used this is the most "stable" way to do this.

You can also make a plugin that only stores your values, that would work like this. You only would have to include/use it on every page so you can access your config variables in this way.

But since you want a "catch all no matter where" solution, this is the way to go really.

thiago9438
thiago9438

Thanks for help!

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.