[英]Typo3 list children of a specific system category (news extension)
我在Typo3中有一個系統類別樹:
─┬─A─┬─A1
│ └─A2
│
└─B─┬─B1
┼─B2
└─B3
我要渲染B樹的子級。
在每個子新聞項上,我都能在每次迭代中獲得字符串中的類別
<f:for each="{news}" as="newsItem" iteration="iterator">
<!-- render partial="List/ServiceItem" -->
<div
<f:if condition="{newsItem.categories}">
data-groups="[<f:for each="{newsItem.categories}" as="category" iteration="iteratorCategories">'{category.title}'<f:if condition="{iteratorCategories.isLast}"><f:then></f:then><f:else>,</f:else></f:if></f:for>]"
</f:if>
>{newsItem.title} & other stuff</div>
</f:for>
我正在使用Shuffle.js來過濾列表,我需要所有B樹子來創建組控件,而我嘗試了以下方法:
<div class="news-list-category"> categories:
<f:for each="{categories}" as="category" iteration="iteratorCategories">
<f:if condition="{category.title} == 'B'">
{category.title}
<f:debug>{category.children}</f:debug>
<f:if condition="{category.children}">
children:
<f:for each="{category.children}"
as="subCategory"
iteration="iteratorSubCategories">
<span>{subCategory.title}</span>
</f:for>
</f:if>
</f:if>
</f:for>
</div>
category.children和category.item.children返回null
如果condition =“ {category.title} =='B'到達正確的第一級物品
我使用了typo3conf / ext / news / Resources / Private / Templates / Styles / Twb / Templates / Category / List.html
作為參考
我是否應該在打字稿中這樣做並傳遞給流體
<f:cObject typoscriptObjectPath="lib.myTyposSubCategoryList" />
我去看看我是否可以得到Typoscript來渲染它,但是想要一個流暢的解決方案
謝謝
所以我建議你這樣做:
在T3后端中創建一個新的新聞模塊。 並選擇類別作為顯示模塊。 您可以在主題文件夾的Templates/Category/List.html
文件中自定義模塊,以更改結構並使其與shuffle.js
一起shuffle.js
。 該模塊需要與列表模塊包含在同一頁面上,確保選擇要在其中找到列表模塊的站點ID,並在“設置”選項卡中禁用“ Disable overwriting of plugin settings
復選框。
在模塊中,您只需選擇要顯示的類別。 我認為這可能是最簡單的方法。
我使用相同的方法將類別菜單轉換為下拉菜單:
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="General" />
<!--
=====================
Templates/Category/List.html
-->
<f:section name="content">
<f:if condition="{categories}">
<f:then>
<div class="news-cat-view side-news">
<h3><f:translate key="categories" /></h3>
<f:render section="categoryTree" arguments="{categories:categories,overwriteDemand:overwriteDemand}" />
</div>
</f:then>
<f:else>
<f:translate key="list_nocategoriesfound" />
</f:else>
</f:if>
</f:section>
<f:section name="categoryTree">
<ul>
<f:for each="{categories}" as="category">
<li>
<f:if condition="{category.item.uid} == {overwriteDemand.categories}">
<f:then>
<a href="javascript:;">{category.item.title}</a>
</f:then>
<f:else>
<a href="javascript:;">{category.item.title}</a>
</f:else>
</f:if>
<f:if condition="{category.children}">
<f:render section="categoryTreeSub" arguments="{categories: category.children,overwriteDemand:overwriteDemand}" />
</f:if>
</li>
</f:for>
<li class="parent reset" style="display: none;"><f:link.page pageUid="22"><f:translate key="back-link" /></f:link.page></li>
</ul>
</f:section>
<f:section name="categoryTreeSub">
<ul>
<f:for each="{categories}" as="category">
<li>
<f:if condition="{category.item.uid} == {overwriteDemand.categories}">
<f:then>
<f:link.page title="{category.item.title}" class="active" pageUid="{settings.listPid}"
additionalParams="{tx_news_pi1:{overwriteDemand:{categories: category.item.uid}}}">{category.item.title}
</f:link.page>
</f:then>
<f:else>
<f:link.page title="{category.item.title}" pageUid="{settings.listPid}"
additionalParams="{tx_news_pi1:{overwriteDemand:{categories: category.item.uid}}}">{category.item.title}
</f:link.page>
</f:else>
</f:if>
</li>
</f:for>
</ul>
</f:section>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.