sitegeist / turncoat
Neos CMS 主题设计
Requires
- neos/flow: *
This package is auto-updated.
Last update: 2024-09-06 13:00:14 UTC
README
通过将功能的实现与渲染分离来实现 Neos CMS 的主题设计...
!!! 这是一种实验性方法来测试该概念的可行性 !!!
主要思想是将提供功能(节点类型和集成)的包与提供主题(展示)的包分离。功能包可以是包含文档和菜单的完整站点包,也可以是只提供单个特定节点类型的较小包。
作者与赞助商
- Martin Ficzel - ficzel@sitegeist.de
此包的开发和公开发布得到了我们雇主的大力赞助 http://www.sitegeist.de.
安装
Sitegeist.Turncoat 通过 packagist 提供,可以使用命令 composer require sitegeist/turncoat
安装。
我们使用语义版本控制,每次重大更改都会增加主版本号。
使用方法
选择主题
为每个文档的站点选择主题。为此,必须在站点文档中添加 Sitegeist.Turncoat:Mixin.ThemeSelector
。
'Vendor.Site:Document.Homepage': superTypes: 'Sitegeist.Turncoat:Mixin.ThemeSelector': true
这将为您的站点添加 theme
属性,允许您在所有已安装的主题包之间进行选择。
功能
提供功能
功能实现节点类型和集成层,但将渲染转发到原型 Sitegeist.Turncoat:ThemeRenderer
prototype(Vendor.Site:Content.Example) < prototype(Neos.Neos:ContentComponent) {
renderer = Sitegeist.Turncoat:ThemeRenderer {
feature = "Example"
props {
title = Neos.Fusion:Editable {
property 'title'
}
}
}
}
实现主题
主题包提供所有支持功能的渲染,并使用包类型 neos-themes
。
您可以使用以下命令启动此类包
./flow package:create --package-type neos-themes Vendor.Theme
在主题包中,您必须创建一个名为 Settings.yaml 的文件,并包含以下内容,以确保您的包融合将被加载。
Neos:
Neos:
fusion:
autoInclude:
Vendor.Theme: true
要包含您融合文件夹中的所有功能,您应该在根.fusion 中添加以下行
include: ./**/*.fusion
现在您可以从实现功能开始。
在主题中实现功能
每个功能都是通过在主题包的 Feature
命名空间中提供原型来实现的。
prototype(Vendor.Theme:Feature.Example) < prototype(Neos.Fusion:Component) {
title = null
renderer = afx`
<h1 style="font-family:ComicSans,sans-serif; color:red;">
{props.title}
</h1>
`
}
提供回退渲染
功能可以提供默认的渲染,主题可以覆盖它。为此,可以定义一个提供渲染的回退包。这很有意义,这个回退要么在提供功能的包内部,要么在依赖该包的包中。
prototype(Vendor.Site:Content.Example) < prototype(Neos.Neos:ContentComponent) {
renderer = Sitegeist.Turncoat:ThemeRenderer {
feature = "Example"
fallback = "Vendor.Theme"
props {
...
}
}
}
prototype(Vendor.Theme:Feature.Example) < prototype(Neos.Fusion:Component) {
title = null
renderer = afx`
<h1 style="font-family:Times,serif; color:green;">
{props.title}
</h1>
`
}
贡献
我们非常愿意接受贡献。请发送拉取请求。