traw / vhs-col
一组或多或少有用的 ViewHelpers 和实用工具集合
Requires
- php: ^8.1
- fluidtypo3/vhs: ^7
- giggsey/libphonenumber-for-php: ^8.12
- typo3/cms-extbase: ^11 || ^12 || ^13
- typo3/cms-fluid-styled-content: ^11 || ^12 || ^13
README
一组或多或少有用的 ViewHelpers
用法
命名空间全局注册为 vcol
URI 电话号码
示例:地址电话号码
<f:link.typolink parameter="{vcol:uri.telephone(phoneNumber: address.phone)}">{address.phone}</f:link.typolink>
SVG
渲染 SVG 内容
将 svg 文件引用作为内联 svg html 渲染
<f:format.raw><vcol:renderSvgContent svgReference="{file}"/>/f:format.raw>
Svg VH
从给定的名称渲染 SVG,有 typoscript 配置
文本
管道到 BR
如果您不允许
例如在标题中,您可以使用 |
符号。此 vh 将 | 替换为
标签
杂项
扩展已加载
如果有任何扩展键已加载,则条件
<vcol:extension.extensionLoaded extensionKey="my_ext">
<f:then></f:then>
<f:else></f:else>
</vcol:extension.extensionLoaded>
<vcol:extension.extensionLoaded extensionKey="my_ext">
do something
</vcol:extension.extensionLoaded>
TCA 选项映射 ItemsProcFunction
该字段必须注册此 itemsProcFunc:\TRAW\VhsCol\Configuration\TcaOptionsMap::class . '->addOptions'
您可以为每个字段注册多个条件,例如:“如果条件 A 满足则添加选项 A,如果条件 B 满足则添加选项 B”
用法
为表定义选项映射
$GLOBALS['TCA']['tt_content]['tx_vhscol_option_map'] = [...];
$GLOBALS['TCA']['pages]['tx_vhscol_option_map'] = [...];
为字段定义一个或多个条件/选项数组
'frame_class' => [
[
'conditions' => [
'fields' => [
'fieldName1' => [ values ],
'fieldName2' => [ values ],
],
'functions' => [
'parentPageProperties' => [
'parentPageFieldName' => [ values]
],
'parentContainerProperties' => [
'parentContainerFieldName' => [ values ]
],
],
],
'options' => [
['label', 'dbvalue'],
['label2', 'dbvalue3'],
['label3', 'dbvalue3'],
],
],
[
// other options and conditions
]
],
如果您省略条件数组,则选项将始终添加
条件类型
fields:字段与其中一个值匹配 notFields:字段与所有值都不匹配 functions:函数返回 true 函数可以是 parentPageProperties
或 parentContainerProperties
在 tt_content 中的用法
(例如:Configuration/TCA/Overrides/tt_content.php)
如果满足以下所有条件,则添加选项
- Ctype=textmedia,
- colPos=0 或 1,
- 父页面 doktype 为 100
- 父容器(b13/container)的 CType 为 "row-100" 或 "row-tabs"
$GLOBALS['TCA']['tt_content']['columns']['frame_class']['config']['itemsProcFunc']
= \TRAW\VhsCol\Configuration\TcaOptionsMap::class . '->addOptions';
$GLOBALS['TCA']['tt_content']['tx_vhscol_option_map'] = [
'frame_class' => [
[
'conditions' => [
'fields' => [
'CType' => ['textmedia'],
'colPos' => [0,1],
],
'functions' => [
'parentPageProperties' => [
'doktype' => [100]
],
'parentContainerProperties' => [
'CType' => ['row-100', 'row-tabs']
],
],
],
'options' => [
['label', 'dbvalue'],
],
]
],
];
在页面中的用法
(例如:Configuration/TCA/Overrides/pages.php)
如果满足以下条件,则添加选项 1 和 2
- doktype 是 1(标准页面)
- 父站点是根页面
如果满足以下条件,则添加选项 3 和 4
-
doktype 是 1、10 或 100
-
父页面不是根页面
//将 itemsProcFunc 添加到 pages 字段 $GLOBALS['TCA']['pages']['columns']['layout']['config']['itemsProcFunc'] = \TRAW\VhsCol\Configuration\TcaOptionsMap::class . '->addOptions'; $GLOBALS['TCA']['pages']['tx_vhscol_option_map'] = [ 'layout' => [ [ 'conditions' => [ 'fields' => [ 'doktype' => [1], ], 'functions' => [ 'parentPageProperties' => [ 'is_siteroot' => [1] ], ], ], 'options' => [ ['label1', 'dbvalue1'], ['label2', 'dbvalue2'], ], ], // 如果 doktype 是 1 但父页面不是根页面则添加选项 [ 'conditions' => [ 'fields' => [ 'doktype' => [1,10,100], ], 'functions' => [ 'parentPageProperties' => [ 'is_siteroot' => [0] ], ], ], 'options' => [ ['label3', 'dbvalue3'], ['label4', 'dbvalue3'], ], ] ], ];
也可以与其他表(新闻、地址等)一起使用
待办事项
- 文档