【问题标题】:How to chose the tx_news list template using TypoScript如何使用 TypoScript 选择 tx_news 列表模板
【发布时间】:2014-10-02 07:42:11
【问题描述】:

我正在以tx_news TYPO3 扩展名开始我的“冒险”。我创建了新的列表模板,并在下拉列表中的 flexform 中看到它 - 没关系,但是如何仅使用 TypoScript 选择该模板?有可能吗?

感谢您的帮助。

【问题讨论】:

    标签: typo3 typoscript tx-news


    【解决方案1】:

    我想通了。这是解决方案 - 如果您的模板中有编号为 99 的 templateLayout(如 tx_news 教程中)<f:if condition="{settings.templateLayout} == 99"> 在 TypoScript 中,您应该使用此代码调用 99 布局:

    lib.some_news < lib.news
    lib.some_news = USER
    lib.some_news {
    userFunc = tx_extbase_core_bootstrap->run
    extensionName = News
    pluginName = Pi1
    
    switchableControllerActions.News.1 = list
    
    settings < plugin.tx_news.settings
    settings {
      categories = 7
      templateLayout = 99 # your layout number
      limit = 1
      detailPid = 22
      overrideFlexformSettingsIfEmpty := addToList(detailPid)
      startingpoint = 20
      list {
        media {
          image {
            maxWidth = 588
            maxHeight = 428
            width = 588c
            height = 428c
          }
        }
      }
     }
    } 
    

    【讨论】:

      【解决方案2】:

      只需 3 步。

      1) 将 tepmlate 从 EXT 文件夹复制到网站模板并添加打字稿

      plugin.tx_news {
          view {
              # Additional template paths
              templateRootPaths.110 = youPath/Templates/
              # Additional partial paths
              partialRootPaths.110 = youPath/Partials/
              # Different template for pagination
              widget.Tx_News_ViewHelpers_Widget_PaginateViewHelper.templateRootPath = youPath/Templates/
          }
      }
      

      2) 在您的新“新闻”模板中复制部分内容。像将部分/列表复制到部分/最新(例如) 3)现在你应该编写规则前模板“youPath/Templates/List.html”或/和相同的前 Detail.html(如果需要)

      <!-- Strat template -->
      <f:section name="content">
      
          <f:if condition="{settings.templateLayout}"> <!-- if we heve Layout than include our new partitial -->
      
              <f:then>
      
                  <f:render partial="{settings.templateLayout}/List" arguments="{news: news, settings:settings}"/>
      
              </f:then>
      
              <f:else>
      <!-- ... default Template-->
      

      仅此而已)祝你好运

      【讨论】:

        【解决方案3】:

        使用您的脚本时,我确实收到以下错误。

        找不到键“TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper->switchExpression”的值,因此无法删除该键。

        我也检查了手册 (http://docs.typo3.org/typo3cms/extensions/news/Main/Tutorial/IntegrationWithTs/Index.html),而且这个截图似乎不能正常工作。

        这可能会解决问题:https://forge.typo3.org/issues/59255

        【讨论】:

        • 要回答您的问题,我需要查看您的相关流体模板。无论如何,这与上面的脚本无关 - 所以如果您需要有关流体代码的帮助,最好提出一个新问题(如果它不存在)
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-04-30
        • 1970-01-01
        • 2016-02-04
        • 2020-03-25
        • 1970-01-01
        • 1970-01-01
        • 2016-10-17
        相关资源
        最近更新 更多