TYPO3 Logo
TypoScript Explained
Options
Give feedback View source How to edit Edit on GitHub Full documentation (single file)

TypoScript Explained

About TypoScript

  • Introduction
  • Getting started
    • Quick overview
    • First steps
    • Page
    • Content records
    • Create a menu with TypoScript
    • fluid_styled_content
    • TypoScript objects
      • Objects executing database queries
      • Objects rendering content
      • Further objects
    • TypoScript functions
      • stdWrap
      • getText / data
      • imgResource
      • select
      • split
      • if
      • typolink
      • parseFunc
    • Next steps
  • Using and setting TypoScript
    • Backend Module
    • Add TypoScript in your extension
    • Access TypoScript in an extension
    • Constants
    • The constant editor
    • Register
    • Debugging / analyzing
  • Using and setting TSconfig
    • Setting page TSconfig
    • Setting user TSconfig
    • Conditions
    • PHP API
  • Syntax
    • Identifiers
    • Code blocks
    • Operators
    • Comments
    • Conditions
    • File imports
    • TSconfig differences

Frontend TypoScript

  • Content Objects (cObject)
    • Content objects (general information)
    • CASE
    • Content object array - COA, COA_INT
    • CONTENT
    • EXTBASEPLUGIN
    • FILES
    • FLUIDTEMPLATE
    • HMENU
      • TMENU
        • TMENUITEM
      • Browse - previous and next links
      • Categories HMENU
      • Directory menu - menu of subpages
      • Keywords - menu of related pages
      • Language menu
      • List menu
      • Rootline - breadcrumb menu
      • Updated HMENU
      • Userfunction menu
    • IMAGE
      • GIFBUILDER
        • Examples
        • Note on (+calc)
        • Properties
        • GIFBUILDER objects
          • ADJUST
          • BOX
          • CROP
          • EFFECT
          • ELLIPSE
          • EMBOSS
          • IMAGE
          • OUTLINE
          • SCALE
          • SHADOW
          • TEXT
          • WORKAREA
    • IMG_RESOURCE
    • LOAD_REGISTER
    • RECORDS
    • RESTORE_REGISTER
    • SVG
    • TEXT
    • USER and USER_INT
  • Data processors
    • comma-separated-value
    • database-query
    • files
    • flex-form
    • gallery
    • language-menu
    • menu
    • site
    • site-language
    • split
    • Custom data processors
  • Top-level objects
    • CONFIG & config
    • constants
    • module
    • PAGE
      • PAGE Examples
    • plugin
    • Reserved top-level objects
  • Functions
    • cache
    • Calc
    • Data / getText
    • encapsLines
    • getEnv
    • HTMLparser
    • HTMLparser_tags
    • if
    • imageLinkWrap
    • imgResource
    • makelinks
    • numberFormat
    • numRows
    • optionSplit
    • parseFunc
    • replacement
    • round
    • select
    • split
    • stdWrap
    • strPad
    • tags
    • typolink
  • Simple data types
  • Conditions

Backend TypoScript

  • Page TSconfig Reference
    • mod
      • SHARED
      • web_info
      • web_layout
        • Backend layouts
      • web_list
      • web_view
      • wizards
    • options
    • RTE
    • TCAdefaults
    • TCEFORM
    • TCEMAIN
    • templates
    • tx_*
  • User TSconfig reference
    • admPanel (EXT:adminpanel)
    • auth
    • options
    • page
    • permissions
    • setup
    • TCAdefaults
    • tx_*

Appendix

  • PHP and TypoScript
  • Glossary
  • Sitemap
  1. TypoScript Explained
  2. Data processors
  3. menu
Give feedback Edit on GitHub

menu data processor

New in version 12.1

One can use the alias menu instead of the fully-qualified class name \TYPO3\CMS\Frontend\DataProcessing\MenuProcessor .

The \TYPO3\CMS\Frontend\DataProcessing\MenuProcessor , alias menu, utilizes HMENU to generate a list of menu items which can be assigned to FLUIDTEMPLATE as a variable.

Additional data processing is supported and will be applied to each record.

Table of contents

  • Options
  • Example: Two level menu of the web page

Hint

The third party extension b13/menus also provides menu processors like \B13\Menus\DataProcessing\TreeMenu and \B13\Menus\DataProcessing\BreadcrumbsMenu.

Refer to the manual of the extension b13/menus for more information.

Options

Name Type Default
levels
integer / stdWrap 1
expandAll
boolean / stdWrap 1
includeSpacer
boolean / stdWrap 0
titleField
string / stdWrap "nav_title // title"
as
string "menu"

levels

levels
Type
integer / stdWrap
Required
true
Default
1
Example
5

Maximal number of levels to be included in the output array.

expandAll

expandAll
Type
boolean / stdWrap
Required
true
Default
1
Example
0

Include all submenus (1) or only those of the active pages (0).

includeSpacer

includeSpacer
Type
boolean / stdWrap
Required
true
Default
0
Example
1

Include pages with type "spacer".

titleField

titleField
Type
string / stdWrap
Required
true
Default
"nav_title // title"
Example
"subtitle"

Fields to be used as title.

as

as
Type
string
Required
false
Default
"menu"

Name for the variable in the Fluid template.

Hint

Additionally, all HMENU options are available.

Example: Two level menu of the web page

Please see also About the examples.

TypoScript

Using the MenuProcessor the following scenario is possible:

EXT:examples/Configuration/TypoScript/DataProcessors/Processors/MenuProcessor.typoscript
tt_content {
    examples_dataprocmenu =< lib.contentElement
    examples_dataprocmenu {
        templateName = DataProcMenu
        # Before TYPO3 v12.1 you have to specify the fully-qualified class name of the processor
        # dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
        # Since TYPO3 v12.1 one can also use the available alias
        dataProcessing.10 = menu
        dataProcessing.10 {
            levels = 2
            as = headerMenu
            expandAll = 1
            includeSpacer = 1
            titleField = nav_title // title
            dataProcessing {
                # Before TYPO3 v12.1 you have to specify the fully-qualified class name of the processor
                # dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
                # Since TYPO3 v12.1 one can also use the available alias
                10 = files
                10 {
                    references.fieldName = media
                }
            }
        }
    }
}
Copied!
The Fluid template

This generated menu can be used in Fluid like this:

EXT:examples/Resources/Private/Templates/ContentElements/DataProcMenu.html
<html data-namespace-typo3-fluid="true" xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
   <h2>Data in variable headerMenu</h2>
   <f:debug inline="true">{headerMenu}</f:debug>

   <h2>Output</h2>
   <ul class="nav nav-pills">
      <f:for each="{headerMenu}" as="menuItem">
         <li class="nav-item {f:if(condition: menuItem.hasSubpages, then: 'dropdown')}">
            <f:if condition="{menuItem.hasSubpages}">
               <f:then>
                  <!-- Item has children -->
                  <a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">
                     <f:if condition="{menuItem.files}">
                        <f:image image="{menuItem.files.0}" class="" width="20"/>
                     </f:if>
                     {menuItem.title}
                  </a>
                  <div class="dropdown-menu">
                     <f:for each="{menuItem.children}" as="menuItemLevel2">
                        <f:if condition="{menuItemLevel2.spacer}">
                           <f:then><div class="dropdown-divider"></div></f:then>
                           <f:else>
                              <f:link.page pageUid="{menuItemLevel2.data.uid}"
                                           class="dropdown-item {f:if(condition: menuItemLevel2.active, then: 'active')}">
                                 {menuItemLevel2.title}
                              </f:link.page>
                           </f:else>
                        </f:if>
                     </f:for>
                  </div>
               </f:then>
               <f:else>
                  <!-- Item has no children -->
                  <f:link.page pageUid="{menuItem.data.uid}" class="nav-link {f:if(condition: menuItem.active, then:'active')}">
                     <f:if condition="{menuItem.files}">
                        <f:image image="{menuItem.files.0}" width="20"/>
                     </f:if>
                     {menuItem.title}
                  </f:link.page>
               </f:else>
            </f:if>
         </li>
      </f:for>
   </ul>
</html>
Copied!
Output

The array now contains the menu items on level one. Each item in return has the menu items of level 2 in an array called children.

  • Previous
  • Next
Reference to the headline

Copy and freely share the link

This link target has no permanent anchor assigned. You can make a pull request on GitHub to suggest an anchor. The link below can be used, but is prone to change if the page gets moved.

Copy this link into your TYPO3 manual.

  • Home
  • Contact
  • Issues
  • Repository

Last rendered: Jun 05, 2025 06:22

© since 2012 by the TYPO3 contributors
  • Legal Notice
  • Privacy Policy