[TYPO3-core] SWFOBJECT object and JavaScript placement

François Suter fsu-lists at cobweb.ch
Wed May 9 17:40:15 CEST 2012


Hi all,

I have stumbled on an issue which I'm really unsure how it should be 
solved at best, hence I would like your opinion.

The situation:
The SWFOBJECT object includes some JS when being rendered. It adds 
"contrib/flashmedia/swfobject/swfobject.js" to the list of JS files to 
include in the header and adds a specific JS code for each content 
element as inline code using t3lib_PageRenderer::addJsInlineCode(). So 
far, so good.
During rendering a global page template is used, as defined with TS 
property config.pageRendererTemplateFile (which defaults to 
"typo3/sysext/cms/tslib/templates/tslib_page_frontend.html"). The inline 
JS replaces marker ###JS_INLINE### and the header JS libraries replace 
marker ###JS_INCLUDE###. In the default template ###JS_INLINE### comes 
*after* ###JS_INCLUDE###.

The problem:
In theory it is possible to define a custom template and move the 
markers around. We did so for a given project to have ###JS_INLINE### 
*before* ###JS_INCLUDE###. This breaks the SWFOBJECT because it causes a 
JS error ("swfobject is not defined"). This makes so that - in practice 
- moving the markers around is not possible, because it breaks the 
SWFOBJECT object.

A possible solution:
I would be tempted to change the SWFOBJECT rendering to use 
t3lib_PageRenderer::addJsFooterInlineCode() which solves my current 
problem, but still leaves the possibility for another issue: if someone 
switches ###JS_INCLUDE_FOOTER### and ###JS_INLINE_FOOTER### makers, they 
are still screwed. I currently don't see a way - given the available API 
- to make sure that the swobject.js library and the specific code is 
loaded in the right order no matter what was done to the page template.

Note:
This does not affect the QTOBJECT because it still uses the "old way" of 
including the specific JS (i.e. as a script tag directly in the page). 
This was changed for the SWFOBJECT, because it broke when the JS file 
inclusion were moved to the footer using config.moveJsFromHeaderTo 
Footer (see http://forge.typo3.org/issues/25258).

Any ideas how to solve this conundrum?

-- 

Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch


More information about the TYPO3-team-core mailing list