Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typo3 menu with anchors

I need help at building a menu with Typo3. Currently I build my menu like this in 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>
}

But like this, Typo3 uses the page tree to create the navigation. Now I want to add anchors from the page itself to my navigation. The TS which I found out to do this look like this:

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>
  } 
}

This works fine, but how do I combine my theese both?

Finally, I want to have something like this:

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

I hope that somebody can help me.

like image 968
Marcel Avatar asked Mar 17 '15 14:03

Marcel


1 Answers

Have a look at the TSref for TMENU items: http://docs.typo3.org/typo3cms/TyposcriptReference/MenuObjects/Tmenuitem/Index.html

There's a property called "after" that can be used to insert any TS object right after the current menu item and before rendering the subpages of the current menu item.

This solution is a bit hackish (in regard to the wraps), but you'll get the idea ;-)

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 >
}
like image 103
Kitze Avatar answered Sep 23 '22 02:09

Kitze