
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.
Related posts:
- MODx – Include Page Content Snippet
- Determing Login State (MODx)
- Changing MODx Managers Document Tree View Nodes







Miro 16 March 2010 5:42 pm
Thanks!
Simple fix without update version of MySQL!
Thanks again
Miro from Calgary