使用锚链接构建菜单作为第二个菜单级别

时间:2012-12-07 12:41:07

标签: typo3 typoscript

我正在处理菜单,将第一级显示为普通链接。第二个菜单级别应该从内容元素构建为锚点菜单。灵感来自this post我构建了以下ts:

lib.footerMenu = HMENU
lib.footerMenu {
1 = TMENU
1 {
    wrap = <ul class="nav">|</ul>
    noBlur = 1

    NO = 1
    NO {
        wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
        ATagParams = class="first" |*| |*| class="last"
        after.cObject = CONTENT
        after.cObject {
            table = tt_content
            select {
                pidInList = this
                orderBy = sorting
                where = colPos=1
                languageField = sys_language_uid
            }
            wrap = <ul>|</ul>
            renderObj = TEXT
            renderObj {
                field = header   
                dataWrap = <li><a href="#c{field:uid}">|</a></li>
            }
        }
     }
  }
}

产生类似的东西('Arnold ipsum。'和'你到底是谁。'是主页的CEs):

<ul class="nav">
    <li class="first"><a href="/" class="first">Homepage</a>
        <ul>
            <li><a href="#c1">Arnold ipsum.</a></li>
            <li><a href="#c11">Who the hell are you.</a></li>
        </ul>
    </li>
    <li><a href="team/">Team</a>
        <ul>
            <li><a href="#c1">Arnold ipsum.</a></li>
            <li><a href="#c11">Who the hell are you.</a></li>
        </ul>
    </li>
    ...
</ul>

现在的问题是, this (pidInList = this)始终保持实际的页面ID,因此实际页面的锚点菜单会附加到所有主菜单项。

如何在每个主菜单下方显示正确的锚点菜单?

1 个答案:

答案 0 :(得分:3)

lib.footerMenu = HMENU
lib.footerMenu {
  1 = TMENU
  1 {
    wrap = <ul class="nav">|</ul>
    noBlur = 1

    NO = 1
    NO {
      wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
      ATagParams = class="first" |*| |*| class="last"
      after.cObject = CONTENT
      after.cObject {
        table = tt_content
        select {
          pidInList.stdWrap.cObject = CASE
          pidInList.stdWrap.cObject {
            key.field = doktype

            default = TEXT
            default.field = uid

            4 = TEXT
            4.field = shortcut
          }
          orderBy = sorting
          where = colPos=1
          languageField = sys_language_uid
          selectFields = uid,pid,header
        }
        wrap = <ul>|</ul>
        renderObj = TEXT
        renderObj {
          field = header
          typolink {
            parameter.field = pid
            section.field = uid
          }
          wrap = <li>|</li>
        }
      }
    }
  }
}

虽然,它可能不适用于旧的TYPO3安装,因为如果我没记错,pidInList以前没有stdWrap。它应该适用于TYPO3 4.5 +。