ttree / outofbandrendering
一个用于在复杂应用程序中轻松渲染Fusion Out of Band的包
3.1.0
2024-01-15 05:53 UTC
Requires
- neos/neos: ^7.3 || ^8.0
README
此包提供了一些助手函数,用于在Neos CMS中处理Fusion Out of Band渲染
包正在开发中,API可能在任何时候更改
如何使用?
编辑您的分发Routes.yaml
并添加所需的路由
-
name: 'Ttree.OutOfBandRendering'
uriPattern: '<TtreeOutOfBandRenderingSubroutes>'
subRoutes:
'TtreeOutOfBandRenderingSubroutes':
package: 'Ttree.OutOfBandRendering'
variables:
'defaultUriSuffix': ''
使用此配置,您可以通过http://www.domain.com/api/v1/rendering
访问URL端点。
检查此包中的Routes.yaml,如果需要自定义URL。
使其工作
端点需要两个参数
- 节点:渲染节点的完整节点路径
- 预设:预设名称,以下提供有关预设的信息
您可以通过两种不同的方式创建预设,在Settings.yaml
中的静态预设和具有您自己的PHP实现的动态预设。预设主要用于限制可以离线渲染的Fusion路径。
静态预设
要使用静态预设,只需在您的Settings.yaml
中写下类似以下的内容
Ttree:
OutOfBandRendering:
presets:
'marketplace:version':
path: 'root<Neos.Fusion:Case>/neosMarketPlaceDocument<Neos.Fusion:Matcher>/element<Neos.MarketPlace:Package>/body<Neos.Fusion:Template>/content/main<Neos.Fusion:Array>/package<Neos.MarketPlace:Package>/versions<Neos.MarketPlace:VersionPreview>'
键marketplace:version
是您的预设名称,并且是该路径允许渲染的Fusion路径。
动态预设
动态预设更灵活,允许您根据给定的节点动态生成Fusion路径。
您需要一个PresetDefintion
对象,简单的方法是像这样扩展AbstractPresetDefinition
use Ttree\OutOfBandRendering\Domain\Model\AbstractPresetDefinition; use Neos\ContentRepository\Domain\Model\NodeInterface; class CustomPresetPresetDefinition extends AbstractPresetDefinition { /** * @param NodeInterface $node * @return string */ public function getFusionPath(NodeInterface $node) { return 'page<Ttree.ArchitectesCh:DefaultPage>/body<Neos.Fusion:Template>/content/main<Neos.Neos:PrimaryContent>/enterpriseProfile<Neos.Fusion:Matcher>/element<Ttree.ArchitectesCh:EnterpriseProfile>/reportSection<Ttree.ArchitectesCh:EnterpriseProfileSection>/content<Ttree.ArchitectesCh:ReportMenu>'; } }
PresetDefinitionInterface
强制您定义以下方法
- PresetDefinitionInterface::getPriority:返回一个整数以定义预设的优先级(较高的优先级更高,类似于Flow Framework的PropertyMapper
- PresetDefinitionInterface::getName:返回预设的名称(用于端点URL)
- PresetDefinitionInterface::canHandle:接收当前文档节点作为参数,并允许您添加更多逻辑以决定预设是否可以处理给定的节点
- PresetDefinitionInterface::getFusionPath:接收当前文档节点作为参数,必须返回要渲染的Fusion路径
接下来是什么?
- 实现授权支持
- 添加JS模块以支持内容加载(附加、替换、无限滚动等)
致谢
由ttree ltd - neos解决方案提供商赞助开发。
我们尽力用爱心打造这个包,我们欢迎赞助、支持请求等,请联系我们。
许可证
在MIT许可下发布,请参阅LICENSE