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
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:
Observed behavior
Calling the route triggers TypoScript condition parser errors like:
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:The empty array means TYPO3’s TypoScript condition matcher does not receive page/rootline/request variables. TYPO3 core’s
PrepareTypoScriptFrontendRenderingprovides variables such as:Without these, TYPO3 cannot derive
tree, so common frontend TypoScript conditions fail.Suggested fix
Build condition matcher variables.
Version*
4.x