In TYPO3 6.x, how to get defaultJS, when config.disableAllHeaderCode is enabled?

487 Views Asked by At

I set config.disableAllHeaderCode = 1 in my recent TYPO3 sites, as I want full control over the page template.

But this not only throws out the html tag etc., but also the default Js (which could be used to uncrypt mailto-Links.

One solution would be to copy this TYPO3-generated JS from the core code and insert it manually. Very simple: just set config.disableAllHeaderCode = 0, load the page once, copy the js, done. But, in case of an update or settings change, this might break.

So: is it possible to access this "default JS" via typoscript and assign it to the PAGE object?

3

There are 3 best solutions below

0
On BEST ANSWER

Have a look at https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/frontend/Classes/Page/PageGenerator.php. You will see that the spam protection code is hardcoded and only added to the page output if config.disableAllHeaderCode is not set.

Therefore I don't see a possibility to do that. Therefore the answer seems to be no, unless you XCLASS the PageGenerator. I would just copy the JavaScript code; I'm using TYPO3 for some years now and wouldn't remember that the spam protection code ever changed.

0
On

years later, finally, it's much easier. In TYPO3 v12 the script can be included as a single file which resides in EXT:frontend/Resources/Public/JavaScript/default_frontend.js.

1
On

There is a solution I think. Go to /typo3/sysext/cms/tslib/templates. There is a file tslib_page_frontend.html. This file is responsible for rendering the whole page including the head. You can define a new path to the above mentioned file. For example set the following code:

config.pageRendererTemplateFile = PATH_TO_YOUR_THEME//Resources/Private/Core/tslib_page_frontend.html

respectively

page.config.pageRendererTemplateFile = PATH_TO_YOUR_THEME//Resources/Private/Core/tslib_page_frontend.html

The new template file can look like the following small snippet:

###JS_INLINE###
###BODY###

That way the inline JS is still rendered (and I think the spam protections JS is inline JS - which can be stored in external files).