TYPO3 tx_news:特定于类别的CSS样式

问题描述 投票:1回答:1

我正在使用Typo3 V9和G.Ringer的tx_news扩展名。该扩展程序运行良好,只有一个我没有发现的功能:对于不同的新闻类别,我想在列表视图中为每个类别设置不同的teasertext样式。

因此,我需要一个针对每个类别而有所不同的CSS类(最好是将类别记录的UID直接映射到CSS类中)。我该怎么做?

typo3 fluid typo3-9.x tx-news
1个回答
3
投票

受到部分类别的启发(ext:news / Resources / Private / Partials / Category / Items.html):

<f:section name="category-classes">
    <f:for each="{categories}" as="category"> cat-class-{category.uid}</f:for>
</f:section>

并将其构建到您的模板中(列表,详细信息...)

例如列表项(ext:news / Resources / Private / Partials / List / Items.html)从[

修改第8行
<div class="article articletype-{newsItem.type}{f:if(condition: newsItem.istopnews, then: ' topnews')}" itemscope="itemscope" itemtype="http://schema.org/Article">

to

<div class="article articletype-{newsItem.type}{f:if(condition: newsItem.istopnews, then: ' topnews')}{f:render(section:'category-classes', arguments:'categories:newsItem.categories')}" itemscope="itemscope" itemtype="http://schema.org/Article">
© www.soinside.com 2019 - 2024. All rights reserved.