agence-raid/sulu-site-configuration-bundle
最新稳定版本:v1.0.2
Composer 安装命令:
composer require agence-raid/sulu-site-configuration-bundle
包简介
Sulu CMS bundle for managing per-webspace site configuration
README 文档
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');
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-14