Warning: You are browsing the documentation from version 4 to 10 of Pimcore. Please visit https://pimcore.com/docs/platform/ for the latest versions of Pimcore.
Version: Edit on GitHub

Website Settings

The Website Settings give you the possibility to configure website-specific settings, which you can access in every controller and view.

Examples:

  • ReCAPTCHA public & private key
  • Locale settings
  • Google Maps API key
  • Defaults
  • ....

Access the Settings

In controllers and views, you can use view helpers or argument resolves to access the config. The returned configuration is a Pimcore\Config\Config object containing your settings.

Example Configuration

Website Setting Config

Usage in a template:

{# access the whole configuration #}
{{ pimcore_website_config() }}

{# or only a single value #}
{{ pimcore_website_config('googleMapsKey') }}

{# you can pass a default value in case the value is not configured #}
{{ pimcore_website_config('googleMapsKey', 'NOT SET') }}

Usage in a controller:

<?php
class TestController
{
    public function testAction(\Pimcore\Config\Config $websiteConfig)
    {
        $recaptchaKeyPublic = $websiteConfig->get('recaptchaPublic');
    }    
}

Manipulate the values in a Controller

If you want to change the value of a website setting from your PHP script, for example from a controller, you can use this code.

<?php
class TestController
{
    public function testAction()
    {
        // get the "somenumber" setting for "de"
        // if the property does not exist you will get the setting with not language provided
        $somesetting = \Pimcore\Model\WebsiteSetting::getByName('somenumber', null, 'de');
        $currentnumber = $somesetting->getData();
        //Now do something with the data or set new data
        //Count up in this case
        $newnumber = $currentnumber + 1;
        $somesetting->setData($newnumber);
        $somesetting->save();
    }
}