[TYPO3] add css and javascript to new extension

Tapio Markula tapio.markula at xetpoint.fi
Mon Dec 31 08:49:02 CET 2007


Jeroen Visser kirjoitti:
> Hi,
> The CSS works by adding it to the file setup.txt in static/css/ 
> directory. Now I hoped to do the same for
> the javascript that is needed. So I made a file static/js/setup.txt
> 
> In this file I added the following code (which works when adding it to 
> my setup.):
> 
> plugin.my_new_ext {
> page.headerData.50 = TEXT
> page.headerData.50.value (
> <script src="typo3conf/ext/my_new_ext/static/js/myscript.js" 
> type="text/javascript"></script>
> )
> }
> 
> Unfortunately this does not work. 

page.headerData is *generic* ts Config - you should *not* put it inside 
plugin configuration section but just:

page.headerData.50 = TEXT
page.headerData.50.value (
<script src="typo3conf/ext/my_new_ext/static/js/myscript.js"
  type="text/javascript"></script>
)


Works, if in not overwritten by another definition for page.headerData.50.

At that mean
$GLOBALS['TSFE']->additionalHeaderData['somekey'] = '<script src ...

is better because that can't be overwritten


More information about the TYPO3-english mailing list