[quote=“Preacher”]
edashboard
P.S.
You also need to not allow yii to load the following scripts in some cases:
$cs=Yii::app()->clientScript;
$cs->scriptMap=array(
'jquery.js'=>false,
'jquery-ui.js'=>false,
'jquery.ajaxqueue.js'=>false,
'jquery.metadata.js'=>false,
'bootstrap.min.css' => false,
'bootstrap-yii.css' => false,
);
And then if you use bootstrap you can load it last e.g.
$cs = Yii::app()->clientScript;
$cs->registerScriptFile('script10',yii::app()->baseURL . '/js/bootstrap.min.js');
Has anyone used this extension.
Works fine as long as you load booster / bootstrap in the correct order. But one thing it is lacking is the ability to store the sorted locations.
Figured it out for anyone wanting this added feature:
Add this to the view that contains the dashboard and change the handle and the id selector to match yours.
The example shows this for the portlet:
<div class="column1">
<?php $obj->addPortlet('feeds', 'Feeds', 'FEEDS PORTAL');?>// portlet id, name, content
<?php $obj->addPortlet('news', 'News', $this->renderPartial('_news',false,true));?>
</div>
I added the following id to mine: #boxes
e.g
<div id="boxes" class="column1">
<?php $obj->addPortlet('feeds', 'Feeds', 'FEEDS PORTAL');?>// portlet id, name, content
<?php $obj->addPortlet('news', 'News', $this->renderPartial('_news',false,true));?>
</div>
<script type="text/javascript">
$(document).ready(function() {
function restoreOrder(id,strCookieName) {
var list = $("#"+id);
if (list == null) return
// fetch the cookie value (saved order)
var cookie = $.cookie(strCookieName);
if (!cookie) return;
// make array from saved order
var IDs = cookie.split(",");
// fetch current order
var items = list.sortable("toArray");
//alert(items);
// make array from current order
var rebuild = new Array();
for ( var v=0, len=items.length; v<len; v++ ){
rebuild[items[v]] = items[v];
}
for (var i = 0, n = IDs.length; i < n; i++) {
// item id from saved order
var itemID = IDs[i];
if (itemID in rebuild) {
// select item id from current order
var item = rebuild[itemID];
// select the item according to current order
var child = $("div#"+id+".ui-sortable").children("#" + item);
// select the item according to the saved order
var savedOrd = $("div#"+id+".ui-sortable").children("#" + itemID);
// remove all the items
child.remove();
// add the items in turn according to saved order
// we need to filter here since the "ui-sortable"
// class is applied to all ul elements and we
// only want the very first! You can modify this
// to support multiple lists - not tested!
$("div#"+id+".ui-sortable").filter(":first").append(savedOrd);
}
}
}
/* var arrValuesForOrder = ["2", "1", "3", "4"];
var ul = $("#boxes"),
items = $("#boxes div.con");
for (var i = arrValuesForOrder[arrValuesForOrder.length - 1]; i >= 0; i--) {
// arrValuesForOrder[i] element to move
// i = index to move element at
ul.prepend(items.get(arrValuesForOrder[i] - 1));
}
*/
function setOrder(id,strCookieName) {
$("#"+id).sortable({
handle : '.portlet-header',
update: function() {
$.cookie(strCookieName, $("#"+id).sortable("toArray"), { expires: 7, path: "/" });
//var order = $("#boxes").sortable("toArray");
//alert(order);
}
});
}
setOrder("boxes","boxesSortOrder")
restoreOrder("boxes","boxesSortOrder");
setOrder("boxes2","boxesSortOrder2")
restoreOrder("boxes2","boxesSortOrder2");
});
</script>
That’s it hopefully it will save someone some serious headache.