[TYPO3-mvc] Bug 5385 : getPageRenderer() fails with uncached action

Xavier Perseguers typo3 at perseguers.ch
Tue May 25 11:39:01 CEST 2010


Hi,

> I just stumble across bug 5385 [1] which found that basically says that
> using
>
> $GLOBALS['TSFE']->getPageRenderer()-> variousMethods
>
> does not work for uncached actions.
>
> For instance. Adding CSS or JS only works when using a cached action.
> Does someone already have a working solution for that?

Well, as I'm still a bit asleep :-/ It cannot work as it is incompatible 
with how TYPO3 handles non-cached content.

As you know, non-cached content is stored as a special marker in the 
whole (cached) page. And this marker is replaced by the USER_INT content 
when the page is requested. As such, there is no way to use pageRenderer 
to add further information to the page header...

However the trick is to use

$this->response->addAdditionalHeaderData('
	<script type="text/javascript" src="/path/to/your/script.js"></script>');

The same for CSS, ...

Cheers
Xavier


More information about the TYPO3-project-typo3v4mvc mailing list