2

我尝试使用 TYPO3 8 中的数据处理器来制作我的菜单。

我的 TypoScript 脚本中有这段代码:

page = PAGE
page{
  10 = FLUIDTEMPLATE
  10 {
      file = fileadmin/abis/templates/BootstrapTmpl.html
      partialRootPath = fileadmin/abis/Partials/
      layoutRootPath =  fileadmin/abis/Layouts/
  }
  dataProcessing {
    10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
    10 {
      entryLevel= 0
      excludeUidList = 27,30,31
      levels = 5
      #includeSpacer = 1
      titleField = nav_title // title
      as = huhu
    }
  }
  ...
}

这是一节中的一个:

<f:section name="myMenu" >
    <f:debug title="title">{huhu}</f:debug>
    <f:cObject typoscriptObjectPath="obj.logo" />
    <ul class="nav navbar-nav navbar-left">
        <f:for each="{huhu}" as="menuItem">
             <li>
                {menuItem.text}
                <f:if condition="menuItem.subItems">
                    <f:render section="myMenu" arguments="{myMenu: menuItem.subItems}" />
                </f:if>
            </li>
        </f:for>
    </ul>
</f:section>

我的 HTML 输出为空。变量 {huhu} 为空。我不知道为什么。有人有想法吗?

4

3 回答 3

7

尝试将您的 dataProcessing 放入page.10

page = PAGE
page {
    10 = FLUIDTEMPLATE
    10 {
        file = fileadmin/abis/templates/BootstrapTmpl.html
        partialRootPath = fileadmin/abis/Partials/
        layoutRootPath =  fileadmin/abis/Layouts/

        dataProcessing {
            10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
            10 {
                entryLevel= 0
                excludeUidList = 27,30,31
                levels = 5
                #includeSpacer = 1
                titleField = nav_title // title
                as = huhu
            }
        }
    }
}
于 2017-09-27T15:30:10.903 回答
4

首先,“数据处理”必须在 page.10 内完成。其次,您必须将您的论点交给“f:render”标签中的部分。不知道您是否这样做,因为您的示例代码中缺少该部分。

于 2017-09-27T15:31:43.790 回答
0

我有一个类似的问题,我的打字稿代码是正确的。但是,我忘了添加

arguments="{_all}"

打电话时

<f:render partial="header" arguments="{_all}" />

在我的布局中。您也可以<f:debug>{huhu}</f:debug>在 Partial 中使用,如果 huhu 为空,您可能已经忘记了arguments="{_all}".

于 2020-03-23T21:17:03.053 回答