A definitive solution for Global attributes/values?

Permalink
Spent quite a while reading old threads, mostly pre 5.7 trying to find the best way to store a set of global values for a site. (Data rather than graphical content).

I have a custom theme that is deployed for multiple sites of a similar type, and it would be great to have a central/global way of setting things like phone number, addresses etc that can be reused throughout the hardcoded template code for ease of deployment.

I see in this 5.6 related thread on the issue:https://www.concrete5.org/community/forums/customizing_c5/global-val... it was suggested that it could be done using a custom define in site.php - e.g:

define('MY_SITEWIDE_URL', 'http://www.google.com');


But obviously in 5.7 site.php has gone. Is there somewhere/a method something similar to this could be done in the latest C5?

mrjcgoodwin
 
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Forgot to say that for the time being am doing it with a json file in each site's root directory, but would be cool if there's a more 'C5 way of doing it' editable via the dashboard or something.
A3020 replied on at Permalink Reply
A3020
I'd use Config for this:

use Config;
Config::set('namespace.group.key');
Config::get('namespace.group.key');
WillemAnchor replied on at Permalink Reply
WillemAnchor
Or use a 2nd database that you can connect to from the different sites.

Here's a thread about that:https://www.concrete5.org/community/forums/customizing_c5/second-mys...

or the luxurious version: use both :D
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Both interesting answers thanks, will consider both.

A3020 - how does this work, are there any docs? This looks more like a method for pragmatically setting then retrieving settings - am I right?

I was thinking more a static file or set of attributes there at point of theme install/site setup.
A3020 replied on at Permalink Best Answer Reply
A3020
You can put your own config file in application/config/some_file.php and add an array to it. The name of the file is the namespace.

With Config::get('some_file.group.key') you can then retrieve settings.

These settings can be set with Config::set. So if your theme is installed by a package, your package can write some default settings to a config file.

You can find example config files in the concrete/config folder.
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Awesome thanks - didn't know you could do this.

My config file would be manually edited anyway prior to installing a site, but interesting nonetheless to see how it can be set dynamically too.
PineCreativeLabs replied on at Permalink Reply
PineCreativeLabs
There's an addon available that does this.

https://www.concrete5.org/marketplace/addons/tokens1...