Skip to content

Typoscript conditions can't be parsed #35

Description

@infabo

Frontend TypoScript conditions fail in AppRoutes with requiresTypoScript: true**
When using AppRoutes in TYPO3 v13 with requiresTypoScript: true, TypoScript conditions that depend on frontend page context fail to parse.

Example route configuration:

pollApi:
    prefix: /api/v1/poll
    routes:
        - name: submitanswer
          path: /submitanswer/{questionuid}/{answeruid}
          defaults:
              handler: Vendor\Extension\Controller\SubmitAnswerEndpoint
              requiresTsfe: true
              requiresTypoScript: true

Observed behavior

Calling the route triggers TypoScript condition parser errors like:

TypoScript condition [traverse(page, "uid") == 1] could not be parsed:
Variable "page" is not valid around position 10 for expression `traverse(page, "uid") == 1`.

TypoScript condition [21 in tree.rootLineIds] could not be parsed:
Variable "tree" is not valid around position 7 for expression `21 in tree.rootLineIds`.

TypoScript condition [tree.pagelayout === 'pagets__plugin' && 45 in tree.rootLineIds] could not be parsed:
Variable "tree" is not valid around position 1 for expression `tree.pagelayout === 'pagets__plugin' && 45 in tree.rootLineIds`.

Expected behavior

AppRoutes should initialize TypoScript condition matching with the same frontend context variables TYPO3 core provides during normal frontend rendering, so conditions using page, tree.rootLineIds, tree.pagelayout, etc. work.

Cause
Sinso\AppRoutes\Service\FrontendInitialization::createFrontendTypoScript() currently calls:

createSettingsAndSetupConditions(..., [], ...)
createSetupConfigOrFullSetup(..., [], ...)

The empty array means TYPO3’s TypoScript condition matcher does not receive page/rootline/request variables. TYPO3 core’s PrepareTypoScriptFrontendRendering provides variables such as:

request
pageId
page
fullRootLine
localRootLine
site
siteLanguage
tsfe

Without these, TYPO3 cannot derive tree, so common frontend TypoScript conditions fail.

Suggested fix

Build condition matcher variables.

Version*

4.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions