I need that all .js zii files are placed at the end with CClientScript :: POS_END. But I need to do it in the configuration file. I see that I can do ‘*. Js’ => ‘all.js’, but I have not figured out how to assign the position. A help?
I don’t know if I completely understand what you are trying to do but if you want to change the default behavior for CCLientScript - and in your case I assume registerScript - you would have to modify this:
public function registerScript($id,$script,$position=self::POS_READY)
{
$this->hasScripts=true;
$this->scripts[$position][$id]=$script;
if($position===self::POS_READY || $position===self::POS_LOAD)
$this->registerCoreScript('jquery');
$params=func_get_args();
$this->recordCachingAction('clientScript','registerScript',$params);
return $this;
}
to
public function registerScript($id,$script,$position=self::POS_END)
{
$this->hasScripts=true;
$this->scripts[$position][$id]=$script;
if($position===self::POS_READY || $position===self::POS_LOAD)
$this->registerCoreScript('jquery');
$params=func_get_args();
$this->recordCachingAction('clientScript','registerScript',$params);
return $this;
}
Or whenever you call registerScript simply pass POS_END.
I’ve tried to create in components folder the class MyClientScript, then i’ve extended CClientScript and i’ve overwrited:
class MyClientScript extends CClientScript {
public function registerScriptFile($url,$position=parent::POS_END) {
parent::registerScriptFile($url, $position);
}
public function registerScript($id, $script, $position = parent::POS_END) {
parent::registerScript($id, $script, $position);
}
But scripts like jquery.cookie remain on <head> section.
Obviously the debug toolbar tells me that the class MyClientScript is loaded correctly.