contao/import — Issue #3600: Make javascript and stylesheets in BE Module handled as an array
Author: importer
Created: 2011-11-29 21:52:27+00:00
State: open
Labels: backend, Feature

Currently we have in Backend.php::getBackendModule() (line 95):

```
// Add module style sheet
if (isset($arrModule['stylesheet']))
{
$GLOBALS['TL_CSS'][] = TL_SCRIPT_URL . $arrModule['stylesheet'];
}

// Add module javascript
if (isset($arrModule['javascript']))
{
$GLOBALS['TL_JAVASCRIPT'][] = TL_SCRIPT_URL . $arrModule['javascript'];
}
```

Developers have the problem to add their custom javascript and styles when the module get's extended.
I therefore suggest to change it to:

```
// Add module style sheet
if (isset($arrModule['stylesheet']))
{
$arrStyles=is_array($arrModule['stylesheet'])?$arrModule['stylesheet']:array($arrModule['stylesheet']);
foreach($arrStyles as $css)
{
$GLOBALS['TL_CSS'][] = TL_SCRIPT_URL . $css;
}
}

// Add module javascript
if (isset($arrModule['javascript']))
{
$arrScripts=is_array($arrModule['javascript'])?$arrModule['javascript']:array($arrModule['javascript']);
foreach($arrScripts as $script)
{
$GLOBALS['TL_JAVASCRIPT'][] = TL_SCRIPT_URL . $script;
}
}
```

This way we are backward compatible and developers can add more than one stylesheet by changing the static string to an array if it exists.
On the second hand, we should change the core definitions to be of type array so this check if it is already an array can be omitted from V2.12 on or something like that.

PS: No patchfile this time, sorry. having limited resources atm. :)

--- _Originally created by xtra on November 3rd, 2011, at 11:25pm (ID 3600)_