sulutheme-bundle

Sulu主题包,提供主题功能。

安装次数:257,107

依赖: 1

建议者: 0

安全性: 0

星标: 17

关注者: 10

分支: 15

开放问题: 3

类型:sulu-bundle

3.1.1 2024-07-24 15:18 UTC

README

Official Sulu Bundle Badge

GitHub license GitHub tag (latest SemVer) Test workflow status Sulu compatibility


SuluThemeBundle 提供了在 Sulu 内容管理系统(Sulu)中,使用多个 webspace 添加多个主题以实现不同外观和感受的功能。

为此,该包使用 SyliusThemeBundle 来渲染不同的 Twig 模板和资源文件。每个 webspace 可以有自己的主题。

🚀  安装和使用

安装包

执行以下 composer 命令,将包添加到项目的依赖项中

composer require sulu/theme-bundle

启用包

将包添加到项目的 config/bundles.php 文件中注册的包列表中,以启用包

return [
    /* ... */
    Sulu\Bundle\ThemeBundle\SuluThemeBundle::class => ['all' => true],
];

配置 SyliusThemeBundle

为了使用该包,您必须至少添加以下默认配置

# ./config/packages/sylius_theme.yaml

sylius_theme:
    sources:
        filesystem: ~

默认情况下,该包在 %kernel.project_dir%/themes 目录中查找主题,并寻找名为 composer.json 的主题配置文件。这可以通过 yaml 配置进行更改

sylius_theme:
    sources:
        filesystem:
            filename: theme.json

有关配置源的更多信息,请参阅 SyliusThemeBundle 文档

配置您的主题

每个主题都必须有一个自己的配置文件,形式为 theme.json。有关配置选项的详细信息,请参阅 主题配置参考

主题的最小配置如下

// ./themes/<theme-name-1>/theme.json

{
  "name": "vendor/<theme-name-1>"
}

重要的是,name 必须与 composer 的命名约定(vendor/name)匹配。

创建一个主题

首先,您必须在项目中创建 themes 目录。要创建一个主题,您必须在主题文件夹中创建一个新的目录,其名称为新主题的名称。在新创建的目录中,您必须添加主题配置文件 theme.json。请参阅 配置您的主题。此外,您必须创建紧邻 theme.jsontemplates 目录。然后,您必须填充此文件夹中所有用于该主题的模板和资源。

这会产生以下项目结构

ProjectName
├── composer.json
├── assets
├── bin
├── config
├── templates
├── themes
│   ├── <theme-name-1>
│   │   ├── templates
│   │   │   └── base.html.twig
│   │   └── theme.json
│   └── <theme-name-2>
│       ├── templates
│       │   └── base.html.twig
│       └── theme.json
├── ...
└── ...

将您的主题之一添加到 webspace

每个 webspace 都可以使用不同的主题。可以通过将主题名称 <theme>vendor/theme-name</theme> 添加到您的 webspace 来为特定 webspace 启用主题

<!-- ./config/webspaces/example.xml -->
<webspace xmlns="http://schemas.sulu.io/webspace/webspace"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://schemas.sulu.io/webspace/webspace http://schemas.sulu.io/webspace/webspace-1.1.xsd">
    <name>example.com</name>
    <key>example</key>
    ...
    <theme>vendor/theme-name</theme>
    ...    
</webspace>

❤️  支持和贡献

Sulu 内容管理系统是一个 由社区驱动的开源项目,由多家合作伙伴公司支持。我们致力于完全透明的开发过程,并 非常重视任何贡献

如果您有任何疑问,我们很乐意欢迎您加入我们的官方 Slack 频道。如果您发现了一个错误或缺少某个特定功能,请随意在 sulu/SuluThemeBundle 仓库中 创建一个新问题,并附上相应的标题和描述。

📘  许可证

Sulu 内容管理系统是在 MIT 许可证 的条款下发布的。