[TYPO3-core] RFC: Load javascript libraries

Thomas Hempel thomas at typo3-unleashed.net
Tue Sep 18 20:14:04 CEST 2007


Hi Benjamin,

 >
 > It just should be a nice wrapper so people don't have to write their own
 > workaround for this.
What about a more general approach?
If we use the complete path as $lib parameter we don't have hardcoded 
paths and the lib scripts can have diferent names than the library 
itself. Mootools is an example, where the file is called mootools.v1xxx.js.

So we would have something simple like that:

function loadJavascriptLib($lib)	{
		$lib = htmlspecialchars($lib);
		
		if (!isset($this->JScodeLibArray[$lib]))	{
			$libfile = $this->backPath.$lib;
			$this->JScodeLibArray[$lib] = '<script language="text/javascript" 
src="'.$libfile.'"></script>';
		}
	}
}

$lib could be something like 'contrib/prototype/prototype.js'.

This has only one disadvantage. It could be possible to have two entries 
like

scriptacoulus.js?load=effects and scriptacoulus.js?load=slider

in JScodeLibArray.

But it's the same in your approach.


Greets,
Thomas


--
typo3-unleashed.net


More information about the TYPO3-team-core mailing list