[英]TYPO3, News. How do I define a new list view?
我需要有關新聞(和一些TYPO3)的速成課程。 我想要一個進一步的“顯示內容”插件選項,以顯示自定義新聞列表。
我(相信)理解如何在類newsController中定義一個新的mylistAction方法,以及一個相應的mylist.html模板。
我想念的是如何在BE模塊中獲得(工作中的)mylist選項以將插件插入頁面。 我不確定我還需要更新什么以及如何更新(TCA,語言文件,TS,...)
謝謝您的幫助,干杯,馬里奧
----- 編輯並解決了!
NewsController.php
定義了動作listmAction()
listm.html
在Configuration/Flexforms/flexform_news.xml
我添加了以下行:
<numIndex index =“ 22”>\n <numIndex index =“ 0”> LLL:EXT:news / Resources / Private / Language / locallang_be.xlf:flexforms_general.mode.news_listm\n </ numIndex>\n <numIndex index =“ 1”>新聞-> listm </ numIndex>\n </ numIndex>
在locallang_be.xlf
我添加了行
<trans-unit id =“ flexforms_general.mode.news_listm” xml:space =“ preserve”>\n <source>列出視圖</ source>\n </ trans-unit>
現在,我可以將News插件插入帶有
新的listm選項,並呈現listm模板。 (似乎我也需要刪除緩存)。 好!
修改新聞擴展名不是一個好主意-之后便無法真正對其進行更新。
但是,EXT:news具有添加多個列表視圖的內置方式,如此處所述 。
簡短版:新聞插件中有一個模板選擇器,您可以通過TypoScript向其中添加項目。 在您的pageTS中放入以下內容:
tx_news.templateLayouts {
1 = A custom layout
99 = LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.mode.news_listm
}
您在此字段的后端中所做的選擇將傳遞到變量settings.templateLayout
的視圖。
因此,在您的List.html
模板文件中,您可以執行以下操作:
<f:if condition="{settings.templateLayout} == 99">
<f:then>
<!-- Render template with number 99 here -->
</f:then>
<f:else>
<!-- Render template with number 1 here -->
</f:else>
</f:if>
如果您有多個模板,最好使用EXT:vhs中的switch / case-ViewHelpers或類似的東西。
如果要將插件插入頁面,則需要為其創建自定義前端插件。 就像是
ext_tables.php :
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Namespace.' . $_EXTKEY,
'custom_news',
'Custom News'
);
ext_localconf.php :
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Namespace.' . $_EXTKEY,
'custom_news',
array('CustomNews' => 'mylist'),
// non-cacheable actions
array('CustomNews' => 'mylist')
);
我希望您為此創建了自定義擴展並擴展了newsController。
問候,安東
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.