0
votes

I would like to have a menu mixing pages and sections from current page. For example on page1:

  • section1_from_page1
  • section2_from_page1
  • page2
  • page3

And on page2:

  • section1_from_page2
  • page1
  • page3

Until now, all I'm able to do is to build a new section menu with TypoScript :

lib.sectionnavigation = HMENU
lib.sectionnavigation {
    1 = TMENU
    1 {
        sectionIndex = 1
        sectionIndex.type = header
        sectionIndex.useColPos = -1
        NO {
            ATagBeforeWrap = 1
            linkWrap = <span> | </span> <span class="bar"></span>
            allWrap = <li> | </li>
            allWrap.insertData = 1
        }
    }
    special = list
    special.value.data = page:uid
}

And then add this menu in the Main.html partials from bootstrap_package, with f:cObject :

<f:cObject typoscriptObjectPath="lib.sectionnavigation" />

However, that means that I have to maintain "format" (<li><span>...</span><span class="bar"></span></li>) in both the TypoScript and the Main.html partial which is not convenient. For example, if I change the menu so that I don't need the bar class span, I'll have to update the partial and the TypoScript!

From what I've understood, bootstrap_package defines the main menu in setup.txt:

10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
    levels = 2
    includeSpacer = 1
    as = mainnavigation
}

And then used this in the Main.html partial:

<f:for each="{mainnavigation}" as="mainnavigationItem">

My first plan was to try to built an new array (similar to the one in {mainnavigation}) using TypoScript but I couldn't find a way! I also tried to use a MenuProcessor but didn't succeed either.

Any help would be really appreciated!

Thank you.

1

1 Answers

0
votes

You should use the possibility to identify the current page in typoscript menus with the option to replace the complete rendering for a menu item.

The rendering for current page in a menu can be defined with ACT or CUR (ACT identifies all pages in the root line: current page, parent, grand parent, ...). In your case it may not differ, but you might play it safe:

lib.MainMenu = HMENU
lib.MainMenu {
   wrap = <ul class="nav">|</ul>
   1 = TMENU
   1 {
      NO {
          wrapItemAndSub = <li><span> | </span> <span class="bar"></span></li>
      }
      CUR = 1 
      CUR.doNotShowLink = 1
      // insert your section menu here:  
      CUR.before.cObject < lib.sectionnavigation
   }
}