Snippets
Drop-in recipes for the most common questions.
Customise file output (URL signing, focus point, etc.)
Listen to Enrich. See Events you can listen to.
Override the JSON form output
Implement
Friends
or extend Abstract, then point the form's
rendering at it. See EXT:form.
Add a JSON field to every page response
Extend the page object in TypoScript (loaded after the set):
page.10.fields {
myField = TEXT
myField.value = static value
myDynamic = TEXT
myDynamic.data = TSFE:id
}
Read the current site's frontend URL
Inject Friends
and call with. Returns the
configured frontend for the active site and language.
Detect headless mode in your own code
Inject Friends and
call is. FULL mode always returns true; MIXED
mode only when the request's first Accept header value is exactly
application/ (the strict match is the API contract).
Encode JSON safely from your own code
Inject Friends instead of
calling json_ directly. It applies HTML-attribute-safe hex
flags (JSON_) and the headless.
feature flag for free. Note that it does not throw on encoding
failures — a Json is caught, logged as critical, and the
string " is returned instead.
Decode nested JSON inside an array
Inject Friends and call
decode. Any string value that looks like JSON gets decoded
(nested structures come back as std objects, the outer array
stays an array). Useful when stitching multiple JSON cObjects
together.
Process a file with the same shape as the default response
Inject Friends and
call process.
The output matches what content elements receive — your custom
endpoints stay shape-compatible with the rest of the JSON API.