[TYPO3-dev] Including files to the <head> once

Ingo Renner ingo at typo3.org
Mon Feb 2 23:09:52 CET 2009


Steffen Kamper wrote:

Hi all,

> includeHeaderData {
>     type = script/css/user
>     file = path-to-filename
>     identifier = unique identifier (eg. prototype)
>     inline (
>         string for inline
>     )
>     attributes = xyz (like for css media-attribute etc.
>     position = numeric index
>     blockPosition = header/bodyBegin/bodyEnd
> }

good start, but like always there's room for improvement ;)

what you propose is too complicated or too much effort already, let's 
make it simpler:

PHP wise I would suggest the following:

create a class to represent a page: $page

$page->addCssFile(
	$pathToFile,
	[$blockPosition,] (defaults to xxx, defined as constants)
	[$additionalAttributes = 'predefined defaults']
)

$page->addInlineCss(
	$cssString
	$blockPosition,
	$additionalAttributes
)

your identifier can be created automatically, hashing the file path f.e. 
and doesn't need to be something the user needs to deal with.

The thing would the look similar for JS.

Internally it could then work like Dmitry described it. With the 
introduction of such an API we could also mark the direct access to 
additionaHeaderData as deprecated, two versions later we can then remove 
it and thus enforce the use of the API and thus also a standard way of 
adding JS and CSS to a page.


best
Ingo

-- 
Ingo Renner
TYPO3 Core Developer, Release Manager TYPO3 4.2




More information about the TYPO3-dev mailing list