
Mar 10
MODx – Wayfinder Incorrect Order (menu index)
After a little investigation its down to the SQL statement Wayfinder uses. If you’re using an older version of MySQL (like 5.0.51) the GROUP BY and ORDER BY function behave differently when used together. To get around this problem you either need to update your MySQL server (recommended by sometimes not practical) or to make a quick alteration to the SQL statement in the Wayfinder snippet.
To change the query in the Wayfinder snippet first open it at assets/snippets/wayfinder/wayfinder.inc.php. In Wayfinder 2.0 the query is around line 360. Search for:
1 2 | $sql = "SELECT DISTINCT {$fields} FROM {$tblsc} sc LEFT JOIN {$tbldg} dg ON dg.document = sc.id WHERE sc.published=1 AND sc.deleted=0 AND ({$access}){$menuWhere} AND sc.id IN (".implode(',',$ids).") GROUP BY sc.id ORDER BY {$sort} {$this->_config['sortOrder']} {$sqlLimit};"; |
In the altered query we simply remove the GROUP BY function (which should be fine in 90% of cases). The query now looks like this:
1 2 | $sql = "SELECT DISTINCT {$fields} FROM {$tblsc} sc LEFT JOIN {$tbldg} dg ON dg.document = sc.id WHERE sc.published=1 AND sc.deleted=0 AND ({$access}){$menuWhere} AND sc.id IN (".implode(',',$ids).") ORDER BY {$sort} {$this->_config['sortOrder']} {$sqlLimit};"; |
After that save an upload (if need be). In the majority of cases everything should work fine.
Bookmark or share this page:
Related posts:
- Determing Login State (MODx)
- MODx – Include Page Content Snippet
- Changing MODx Managers Document Tree View Nodes
MSN Contact: contact [at] danielgibbs.net
Dan Gibbs is a web developer, designer and SEO consultant involved in devon web design.






Miro 16 March 2010 5:42 pm
Thanks!
Simple fix without update version of MySQL!
Thanks again
Miro from Calgary
mr5rule 30 December 2010 2:25 pm
thanks for solution…
cisco 6 December 2011 12:15 am
Thanks, very useful, even in 2011 !