TYPO3 将 sys_category 的名称写入 tx_news 处的 class 名称

TYPO3 write name of sys_category into class name at tx_news

我正在使用 TYPO3 8.7 并将 sys_category 的名称写入 tx_news-模板 Item.html 的 class 名称中,如下所示:

<div class="{f:format.case(value: '{newsItem.firstCategory.title}', mode: 'lower')}"> ...

现在我的一个类别有两个词,例如 'my category',因此 classname 结果:

<div class="my category">

如何从 FLUID 中的 class 名称中删除空的“ ”?

感谢您的帮助。

默认情况下这是不可能的 - 但是我看到以下选项:

1) 创建自定义 ViewHelper:这将是最佳解决方案,因为您不需要任何第 3 方扩展作为依赖项。

2) 滥用类别记录的不同字段,如 seo_titledescription 或类似的

3) 您可以使用 EXT:vhs 的替换 VH,参见 https://fluidtypo3.org/viewhelpers/vhs/master/Format/ReplaceViewHelper.html

另外我会考虑使用类别 uid 而不是类别名称。因为名字很脆弱。编辑器可能会重命名某些东西,并且您的 css 代码会中断。但是如果你使用 uids

您可以调整 css 以识别双 类。

.类别 .my.category

仍然应该采用唯一标识符而不是姓名或头衔。