agence-raid / sulu-site-configuration-bundle
Sulu CMS bundle for managing per-webspace site configuration
Package info
github.com/Agence-Raid/sulu-site-configuration-bundle
Type:symfony-bundle
pkg:composer/agence-raid/sulu-site-configuration-bundle
Requires
- php: >=8.2
- doctrine/orm: ^3.0
- sulu/sulu: ^3.0
- symfony/framework-bundle: ^7.0
- symfony/uid: ^7.0
README
Adds a Configuration tab in the Sulu webspace view to manage per-webspace, per-locale site settings (phone, email, social links, logo, etc.) stored as a flexible JSON entity.
Installation
1. Require the package
composer require agence-raid/sulu-site-configuration-bundle
2. Register the bundle
In config/bundles.php:
AgenceRaid\SuluSiteConfigurationBundle\SuluSiteConfigurationBundle::class => ['all' => true],
3. Register the routes
In config/routes/admin.yaml:
agence_raid_sulu_site_configuration_admin: resource: '@SuluSiteConfigurationBundle/config/routes/admin.yaml'
4. Run the migration
bin/adminconsole doctrine:migrations:diff bin/adminconsole doctrine:migrations:migrate
5. Create your form
Create config/forms/webspace_configs/default.xml with the fields you need:
<?xml version="1.0" ?> <form xmlns="http://schemas.sulu.io/template/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/form-1.0.xsd"> <key>site_configuration</key> <properties> <property name="logo" type="single_media_selection"> <meta> <title lang="fr">Logo</title> </meta> </property> <property name="website_email" type="text_line"> <meta> <title lang="fr">Email</title> </meta> </property> </properties> </form>
To override the form for a specific webspace, create config/forms/webspace_configs/{webspace-key}.xml with key site_configuration_{webspace-key}.
6. Grant permissions
Go to Settings → Roles in the Sulu admin and grant {webspace-key}.configuration permissions to the relevant roles.
Usage
In Twig templates
{{ site_config('website_email') }}
{{ site_config('phone', '+33 0 00 00 00 00') }}
{% set logo = sulu_resolve_media(site_config('logo').id, app.request.locale) %}
<img src="{{ logo.url }}" alt="Logo" />
In PHP services
use AgenceRaid\SuluSiteConfigurationBundle\Service\SiteConfigurationService; public function __construct( private readonly SiteConfigurationService $configurationService, ) {} $email = $this->configurationService->get('my-webspace', 'fr', 'website_email'); $all = $this->configurationService->getAll('my-webspace', 'fr');