[英]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.