Registerscriptfile With Custom Htmloptions.

Hi. I’m trying to create a widget encapsulating the new Dropbox Chooser API, which need to be included with a tag like this one:


<script type="text/javascript" src="https://www.dropbox.com/static/api/1/dropbox.js" id="dropboxjs" data-app-key="YOUR_APP_KEY"></script>

As you can see, there’s a non standard attribute [font=“Courier New”]data-app-key[/font] in it. So, this Javascript library can not be inserted using registerScriptFile, since the render generates a fixed [font=“Courier New”]<script>[/font] tag. Of course I can just drop a CHtml::tag(‘script’ blahblah) but this can not be included at the [font=“Courier New”]<head>[/font] section of the page and there’s no way to control if you already included a library in case the widget is used elsewhere in the page (of course I could use a singleton or something else, but it would be cumbersome).

So, something like this would be useful:


public CClientScript registerScriptFile(string $url, integer $position=NULL, array $htmlOptions=NULL)

Notice the new $htmlOptions parameter. I know this means to modify almost 50% of Yii’s core classes, but given the strange tendency of “cloud” providers of including weird ways to use their APIs, it is needed, IMO.

Please take it in consideration.

Opened an issue here: https://github.com/yiisoft/yii/issues/1761

And BTW, I guess extending just CClientScript is not enough for this case, since rendering is done elsewhere.

Спасибо за труды :)))))

Ok, the attached modifications seem to keep backwards compatibility, I will be testing the htmlOptions tomorrow :)

Edit: there was a bug in the classes, the ones attached on 2012-11-28 work fine.

This feature request has been accepted and implemented: https://github.com/yiisoft/yii/issues/1761