carbon / link
Neos CMS 链接助手
2.0.0
2024-03-13 08:44 UTC
Requires
- carbon/eel: ^1.2 || ^2.0
- neos/neos: ^9.0
This package is auto-updated.
Last update: 2024-09-13 10:01:30 UTC
README
Neos CMS 的 Carbon.Link 包
此包为链接编辑器提供了一些融合助手。
安装
大多数时候,您需要对包进行一些小的调整(例如,在 Settings.yaml
中的配置)。因此,将相应的包添加到您的主题包中的 composer 中非常重要。通常,这是位于 Packages/Sites/
下的站点包。要正确安装,请转到您的主题包(例如 Packages/Sites/Foo.Bar
)并运行以下命令
composer require carbon/link --no-update
--no-update
命令可防止自动更新依赖项。在将包添加到您的主题 composer.json
之后,返回到 Neos 安装根目录并运行 composer update
。好了!您想要的包现在已正确安装。
问题
node:// URI 转换需要传递上下文节点
错误是什么意思?
Carbon.Link:Link
和内部的 Neos.Neos:NodeUri
都使用了常用的 documentNode
上下文变量来获取上下文信息,例如语言和工作空间,并计算相对链接。此变量默认在 \Neos\Neos\View\FusionView 中提供,但在 \Neos\Fusion\View\FusionView 中则没有,后者主要用于模型视图控制器应用程序。请确保您手动检索文档节点并将其添加到视图中,例如
<?php class ArticlesController extends ActionController { ... public function listAction(): void { $workspaceName = 'live'; $language = 'en'; $contextProperties = [ 'workspaceName' => $workspaceName, 'invisibleContentShown' => false, 'inaccessibleContentShown' => false, 'dimensions' => [ 'language' => [$language] ], 'targetDimensions' => [ 'language' => $language ] ]; $currentDomain = $this->domainRepository->findOneByActiveRequest(); if ($currentDomain !== null) { $contextProperties['currentSite'] = $currentDomain->getSite(); $contextProperties['currentDomain'] = $currentDomain; } else { $contextProperties['currentSite'] = $this->siteRepository->findFirstOnline(); } $contentContext = $this->contextFactory->create($contextProperties); $site = $contentContext->getCurrentSiteNode(); $this->view->assign('documentNode', $site); } }
许可协议
MIT 许可下发布,请参阅 LICENSE