[eluser]phazei[/eluser]
I added a new method to your Assetlibpro class. For the very lazy:
output_all()
Takes the same parameters output() takes, but it does not require add_css or add_js anywhere at all. It looks in the directory and adds ALL css and/or js files it finds.
In exchange for simplicity you lose the ability to select the order you want stuff added. Only get alphabetical. You also don't get the chance to select a group or module.
But if you're willing to make those sacrifices:
Code:
function output_all($type = 'all'){
if ($type == 'all') {
$css = $this->output_all('css');
$js = $this->output_all('js');
return "$css$js";
}
if (in_array($type,array('css','js'))) {
$dir = $this->_asset_loc('', NULL, $type);
$dir = realpath(trim($dir, "/"));
$dh = scandir($dir);
foreach ($dh as $file) {
if (substr($file,-1*strlen($type)) == $type) {
$add_what = "add_".$type;
$this->$add_what($file);
}
}
return($this->output($type));
}
}
EDITED: This function used to use opendir and readdir. I found out the natural filesystem file order isn't necessarily alphabetical. Caused some issues. (loading plugins before jquery)
I switched it to use scandir which is PHP5 only (there are PHP4 alternatives if you look at the php scandir help page).
Now it works much better