Ordering of sites in Multisite plugin

The ordering of sites in the Multisites listing is a bit off once more than 20 sites are tracked.

I am tracking 22 sites with Piwik. Two have titles that start with A (we’ll call them A1 and A2), and the other 20 have titles starting with C-Z.

The initial view shows sites C-Z, in ascending alphabetical order. Clicking on Next shows A1 and A2, in ascending alphabetical order. These (A1, A2) should be shown at the top of the first screen, while the last 2 of C-Z should be on this second screen.

Also, the text at the bottom reads “1-21 of 22”, when in fact it should read “1-20 of 22”

Ok, answered my own question, a patch that seems to be working is below.

in /plugins/MultiSites/templates/common.js

the .reverse() in:

displayRows(allSites.reverse(), params);

caught my eye, why did it need to be reversed when the sort order was already specified? Of course, this works when there are < $limit sites to display, but it explains the behavior when there are > $limit sites.

Also, the “1 - 21 of 23” is fixed, can someone verify this fix on a site that has < 20 sites?

--- common_ORIGINAL.js    2010-02-18 23:12:06.740830000 -0800
+++ common.js    2010-02-19 00:35:18.918321000 -0800
@@ -46,7 +46,7 @@
         allSites = limitBy(allSites, params);
-    displayRows(allSites.reverse(), params);
+    displayRows(allSites, params);
     showPagination(allUnsortedSites, params);
     params['sitesVisible'] = allSites;
@@ -200,7 +200,7 @@
     var start = (params['page'] - 1) * params['limit'] + 1;
     var count = allSites.length;
-    var end = parseInt(start) + parseInt(params['limit']);
+    var end = parseInt(start) + parseInt(params['limit'] - 1);
     if(end > count) end = count;
     html = '<span>' + (start ) + ' - ' + end + ' of ' + count + '</span>';

and in plugins/MultiSites/Controller.php, change:

protected $order = ‘desc’;


protected $order = ‘asc’;

However, when the table headers are clicked on, the green arrow indicating sort order is now incorrect. I’ve taken a look at the sort function and it looks correct, but there is some sort of disconnect between sort order and arrow indication.

It appears to me that the green arrows indicating sort order are reversed?


points up and


points down.

If these are reversed, the green “sort order” arrow points the way I expect it to (up for ascending, down for descending)

please post your patch (once tested) in the ticket for the MultiSites plugin, ie. http://dev.piwik.org/trac/ticket/1077

it seems that the problem was solved,i was having same thing ,i can’t limit number of websites, style_emoticons/<#EMO_DIR#>/wink.gif