headless
headless copied to clipboard
Document how to use fluid and headless at the same time
Would love to have this feature documented! Would be very handy in one of my upcoming projects 😇
The main problem is that by including headless TypoScript configuration, the page
configuration gets overwritten. I'd rather like to use a separate page type num.
I needed both HTML and JSON output, and did not want to manually include single .typoscript configuration files from headless - because that would probably break with the next headless version.
Instead I opted for a TypoScript condition to only include headless configuration when the JSON page type is present.
Conditional TypoScript file includes differ between TYPO3 v11 and v12: v12 supports @import
inside conditions, while v11 always includes @import
even if they are inside a condition. Using the old INCLUDE_TYPOSCRIPT
is the only way to conditional include .typoscript
files in v11 v11 docs, v12 docs, v12 typoscript changelog.
Since I am on v11 I used the following code:
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:example/Configuration/ApiTypoScript/setup.typoscript" condition="[getTSFE() && getTSFE().type == 2]">
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:example/Configuration/TypoScript/setup.html.typoscript" condition="[getTSFE() && getTSFE().type != 2]">
(I renamed my original setup.typoscript
to setup.html.typoscript
)
My ApiTypoScript/setup.typoscript
imports the headless setup.typoscript
and sets the typeNum
for page
.
getTSFE().type
is necessary, because request.getQueryParams()['type']
does not work with PageTypeSuffix site configuration for nice speaking URLs.
(I am using headless 3.4.0)
isn't https://github.com/TYPO3-Headless/headless/pull/652 also related?
Yes, it is, also it's merged to master, this is PR to 3.x
branch.