[SOLVED] Can't TYPO3.Neos:Menu inherit of/copy itself?


I’d like to render my menu twice within a template. Since I only want to chance some css classes I tried to copy the menu:


page = TYPO3.Neos:Page {

  body {
    parts {

      menus {
        mainMenuStatic = TYPO3.Neos:Menu {
          templatePath = 'resource://Vendor.Site/Private/Templates/TypoScriptObjects/MainMenu.html'

          // menu items as itemCollection
          itemCollection = ${q(site).children('[instanceof TYPO3.Neos:Document]').get()}

          attributes {
            class = 'ui inverted menu'
            id = 'mainMenuStatic'

          current.attributes.class = 'active'
          normal.attributes.class >

        mainMenuSticky < mainMenuStatic
        mainMenuSticky.attributes {
          class = 'ui top fixed menu transition hidden'
          id = 'mainMenuSticky'

Page Template

{namespace neos=TYPO3\Neos\ViewHelpers}
{namespace ts=TYPO3\TypoScript\ViewHelpers}
{namespace media=TYPO3\Media\ViewHelpers}

{parts.menus.mainMenuSticky -> f:format.raw()}
[…] some HTML […]
{parts.menus.mainMenuStatic -> f:format.raw()}

The problem is that the parts.menus.mainMenuStatic node gets rendered, the parts.menus.mainMenuSticky not. (And it really doesn’t get rendered and isn’t just invisible because of the css :stuck_out_tongue: )

What is wrong?


you can try mainMenuSticky < .mainMenuStatic, but I am actually not sure if this works.

I’d suggest instead, that you work more with prototypes, i.e.:

prototype(My.Package:Menu) < prototype(TYPO3.Neos:Menu) {
   ... your menu definitions from above
parts.menus.mainMenuStatic = My.Package:Menu
parts.menus.mainMenuSticky = My.Package:Menu {
   class = 'ui top fixed ...'

Hope this helps :slight_smile:

All the best,

@kurztipp can you quickly let us know whether Sebastians solution worked for you so we can mark this thread as resolved?

Sorry, yes it helped – thank you.

1 Like