[Solved] TYPO3: Add special menu CE and add class=”active”


The answer:


  1. Copy the original fluid template (menu of subpages of selected pages in my case):

    typo3/sysext/fluid_styled_content/Resources/Private/Partials/Menu/Type-1.html
    

    TYPO3 v8: different path and different names

    typo3/sysext/fluid_styled_content/Resources/Private/Templates/xxx.html
    

    To (coherently to the directory you’ll declare in point 4)

    EXT:myExtension/Resources/Private/Partials/Menu/Type-1.html
    
  2. Add a variable that gives the current page id in your setup (libs.ts, probably this can be done easier and this value could be present already for use in point 3, but I wouldn’t know how to code that).

    lib.pageId = TEXT
    lib.pageId.data = page:uid
    
  3. Edit the template (I just give the applicable condition here)

    <f:if condition="{page.uid} == {f:cObject(typoscriptObjectPath: 'lib.pageId')}">
        ...
    </f:if>
    
  4. Include the new fluid template (I overwrite the original one, keeping the original name)

    TYPO3 v8: use lib.contentElement instead of lib.fluidContent

    lib.fluidContent.partialRootPaths.1920 = EXT:myExtension/Resources/Private/Partials/Menu/
    

    Or as I did, include it in your page-setup

    page = PAGE
    page {
        # Page Main template
        10 = FLUIDTEMPLATE
        10 {
            partialRootPaths = EXT:myExtension/Resources/Private/Partials/Menu/
        }
    }
    
  5. If you’d like to add it as an option to the list you re-number the file (like Type-9.html) and add it to the menu in Page TSConfig:

    TYPO3 v8: i did not find a way to add a menu in v8, the config given here does not work …

    TCEFORM.tt_content.menu_type {
       types {
          menu{
             addItems {
                9 = menu of subpages of selected pages active highlighted
             }
          }
       }
    }
    

1

solved TYPO3: Add special menu CE and add class=”active”