【问题标题】:TYPO3, News. How do I define a new list view?TYPO3,新闻。如何定义新的列表视图?
【发布时间】:2016-01-05 10:21:38
【问题描述】:

我需要一个关于新闻的速成课程(以及一些 TYPO3)。我想要更多的“显示内容”插件选项,以显示自定义的新闻列表。

我(相信)了解如何在 newsController 类中定义新的 mylistAction 方法,以及相应的 mylist.html 模板。

我想念的是如何在 BE 模块中获得(工作的)mylist 选项以将插件插入页面。 我不确定我还需要更新什么以及如何更新(TCA、语言文件、TS、...)

感谢您的帮助,干杯,马里奥

----- 编辑已解决 我成功了!

  • 我在NewsController.php 中定义了动作listmAction()
  • 我定义了模板listm.html
  • Configuration/Flexforms/flexform_news.xml 内我添加了行:

    LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.mode.news_listm
    新闻->listm
  • locallang_be.xlf内我添加了行

    列表 m 视图

现在我可以使用
将新闻插件插入页面 新的 listm 选项,并呈现 listm 模板。 (看来我也需要垃圾缓存)。好!

【问题讨论】:

    标签: typo3


    【解决方案1】:

    修改新闻扩展是个坏主意 - 之后您无法真正更新它。

    但是,EXT:news 有一个内置的方式来添加多个列表视图,documented here

    短版:新闻插件中有一个模板选择器,您可以通过 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>
    

    如果您有多个模板,最好使用the switch/case-ViewHelpers from EXT:vhs 或类似的东西。

    【讨论】:

    • 谢谢。如果我想要一个新的 mylistAction 怎么办?有没有类似的技巧?
    【解决方案2】:

    如果您想将插件插入页面,您需要为其创建自定义前端插件。类似的东西

    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。

    问候,安东

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多