Saving and accessing site settings in 5.8

Permalink
Hi There,

In 5.6 we used a constant to store a site version for cache busting css/js. In 5.8, the core config file has been overridden and saved to: /application/config/concrete.php

Then the setting has been added like this...
return array(
    'frontend' => array(
        'site_version' => '?v=2.7.19' // for css and js cache busting
    )
);

Then in the site's header we're trying to access the setting like this...
<?php
    $app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
    $config = $app->make('config');
    $website_version = $config->get('frontend.site_version');
?>
<?= $website_version ?>

But it outputs blank. When outputting $app there's an error...
Object of class Concrete\Core\Application\Application could not be converted to string

Does that path look correct? I don't see those directories anywhere in my install.

Any pointers in the right direction would be much appreciated.

Cheers

Ben

 
cmscss replied on at Permalink Reply
Sorry, I read the docs which pointed me here:https://documentation.concrete5.org/developers/appendix/concrete5-ve...

Which has the following: $app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();

Which might just be an example - does anyone know how to access the config settings?
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Try it like this
return array(
    'frontend' => array(
        'site_version' => '?v=2.7.19', // for css and js cache busting
    ),
);
MrKDilkington replied on at Permalink Best Answer Reply
MrKDilkington
Hi cmscss,

If you added the following code to application\config\concrete.php.
<?php
return array(
    'frontend' => array(
        'site_version' => '?v=2.7.19' // for css and js cache busting
    )
);

You would read it this way:
<?php
$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
$config = $app->make('config');
$website_version = $config->get('concrete.frontend.site_version');
echo $website_version;
?>

I recommend reviewing the documentation.
https://documentation.concrete5.org/developers/packages/storing-conf...
cmscss replied on at Permalink Reply
Thanks guys