'Pass an variable to the template from the middleware in TYPO3 11.5
I want to parse my .browserslistrc in the middleware of TYPO3 to decide which build should be loaded. Yes, I know that I can do it in JavaScript but I want to make the decision earlier.
This is what I return in the process() function:
$response = $handler->handle($request->withAttribute('isModernBrowser', $isModern));
return $response;
isModern is just a boolean which contains the information if a modern or an "old" browser calls the page.
How can I catch isModern in my template?
Solution 1:[1]
ServerRequest is available in $GLOBALS['TYPO3_REQUEST']. Add this object or the specific attribute with $GLOBALS['TYPO3_REQUEST']->getAttribute('isModernBrowser') to view.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | froemken |
