Quick Tip: Loading Dojo 1.7 in Yii

January 19, 2015 •  dojo



Recently i found myself using Yii Framework, a lightweight and superb framework, its quite awesome, however the transition is not as smooth, has i had expected no doubt, its a quick to grasp framework especially coming from someone who uses the Zend Framework,

Unlike Zend Framework the Yii framework is really tied to jQuery, and this really poses a problem for me, because i basically work with Dojo toolkit a lot, and add helpers in Zend to make writing Dojo on the server side as sane as possible or even the Zend_Dojo_Form,

Luckily found a way of loading Dojo in Yii with no problem using the CClientScript Class

 

getClientScript()->registerScript('djConfig','
var dojoConfig={
async:true
		};
		',CClientScript::POS_END);
?>
;getClientScript()->;registerScriptFile("../dojo1.7/dojo/dojo.js",CClientScript::POS_END);
Yii::app()->;getClientScript()->;registerScript("parse","require(['dojo/ready'],function(ready){
ready(function(){
console.log(dojo.version);
});
});",CClientScript::POS_END);

?>;

This basically loads the file and places it at the end of the body content, and the javascript code also
Works well, will have to see if i can extended CWidgets with Dojo, will obviously share the outcome.


Post Comment

Comments

  • Mohamed Cherif BOUCHELAGHEM

    Mohamed Cherif BOUCHELAGHEM 4 years ago 00

    Nice, you can create a custom package like the jquery package in Yii framework like this you can reuse it and you will call dojo like jquery is tied to yii.

    http://danaluther.blogspot.com/2012/03/using-packages-with-clientscript.html
    http://www.yiiframework.com/doc/api/1.1/CClientScript#registerPackage-detail

    I spose to rewrite AJAX calls in CHtml helper and other classes if you want of course.

    I tink jquery ui is not mature like dojo so I hope I can make some dojo dijit based Yii widgets and share it with the community.

  • dojovader

    dojovader 4 years ago 00

    Thanks also i think i would look into the package way in your articles that actually makes much sense, as it avoids loading a script before its dependency,also i think there is a Dojo.Widget Yii Library but i am really looking forward to Yii widgets powered by Dojo Toolkit just like the Zend Framework. please do inform me when you start also you can join the DojoToolkit Community on Facebook, additional support will be given.
    http://www.facebook.com/groups/4375511291/

  • Mohamed Cherif BOUCHELAGHEM

    Mohamed Cherif BOUCHELAGHEM 4 years ago 00

    dojovader, Thanks I hope that helps :) I dont know if I will start this now or better to wait DOJO 2.0, right now there's a dojo dijit powered on the yii extensions repository http://www.yiiframework.com/extension/dojo/ based on Dojo 1.6 and it is not maintained maybe it's a good start point.