带锚的Typo3菜单

时间:2015-03-17 14:11:13

标签: menu anchor typo3 typoscript

我需要帮助建立一个使用Typo3的菜单。目前我在TS中构建我的菜单:

TopNavigation = HMENU
TopNavigation {
  special = directory
  special.value = 3
  entryLevel = 1
  1 = TMENU
  1.expAll = 1
  1.NO = 1
  1.NO.wrapItemAndSub = <li class="parent"> | </li>

  2 < .1
  2.expAll = 0
  2.NO = 1
  2.NO.ATagBeforeWrap = 1
  2.NO.wrapItemAndSub = <li> | </li>
  2.wrap = <ul class="dropdown"> | </ul>
}

但是像这样,Typo3使用页面树来创建导航。现在我想从页面本身添加锚点到我的导航。我发现这样做的TS看起来像这样:

AnchorNavigation = CONTENT
AnchorNavigation  {
  table = tt_content
  select {
    pidInList = this
    orderBy = sorting
    where = colPos=0 AND sectionIndex=1
    languageField=sys_language_uid
  }
  wrap = <ul>|</ul>
  renderObj = TEXT
  renderObj {
    field = header   
    dataWrap= <li><a href="#c{field:uid}">|</a> </li>
  } 
}

这很好用,但我如何将我们的两者结合起来呢?

最后,我想要这样的事情:

Parent Page 1
Parent Page 2
 -> Anchor 1
 -> Anchor 2
 -> Anchor 3
 -> Childpage 1
Parent Page 3
 -> Anchor 1
 -> Anchor 2
 -> Anchor 3
Parent Page 4

我希望有人可以帮助我。

1 个答案:

答案 0 :(得分:2)

查看TMENU项目的TSref:http://docs.typo3.org/typo3cms/TyposcriptReference/MenuObjects/Tmenuitem/Index.html

有一个名为“after”的属性,可用于在当前菜单项之后和呈现当前菜单项的子页面之前插入任何TS对象。

这个解决方案有点hackish(关于包装),但你会得到这个想法; - )

page.5 = HMENU
page.5 {
  special = directory
  special.value = 3
  entryLevel = 1
  1 = TMENU
  1.wrap = <ul>|</ul>
  1.expAll = 1
  1.NO = 1
  1.NO.wrapItemAndSub.cObject = TEXT
  1.NO.wrapItemAndSub.cObject.value = <li class="parent">|</ul></li>
  1.NO.after.cObject = COA
  1.NO.after.cObject {
    # wrap all section links and subpages links.
    # hint: </ul> is done by 1.NO.wrapItemAndSub
    10 = TEXT
    10.value = <ul class="dropdown">

    20 = CONTENT
    20 {
      table = tt_content
      select {
        pidInList.field = uid
        orderBy = sorting
        where = colPos=0 AND sectionIndex=1
        languageField=sys_language_uid
      }
      renderObj = TEXT
      renderObj {
        field = header
        typolink.parameter.field = pid
        typolink.section.field = uid
        dataWrap= <li class="section-link">|</li>
      }
    }
  }
  2 < .1
  2.wrap >
  2.expAll = 0
  2.NO = 1
  2.NO.ATagBeforeWrap = 1
  2.NO.wrapItemAndSub >
  2.NO.wrapItemAndSub = <li class="subpage-link">|</li>
  2.NO.after >
}