Adding further onto this, I noticed by making the Itemids in the links go correctly, my menus weren't highlighting properly.
I'm using a flat menu.
Having another poke around in the code, i found the function which draws the horizonal flat menu - mosShowHFMenu in mod_mainmenu.php.
This uses mosGetMenuLink to create the highlighting. The code in mosGetMenuLink which affected my highlighting is:
Code:
// Active Menu highlighting
$current_itemid = $Itemid;
if ( !$current_itemid ) {
$id = '';
} else if ( $current_itemid == $mitem->id ) {
$id = 'id="active_menu'. $params->get( 'class_sfx' ) .'"';
} else if( $params->get( 'activate_parent' ) && isset( $open ) && in_array( $mitem->id, $open ) ) {
$id = 'id="active_menu'. $params->get( 'class_sfx' ) .'"';
} else {
$id = '';
}
Here we can see that it will highlight if the itemid is equal to the itemid in the menu. the 2nd else which checks the "open" array was never going true, since this function was never being sent the "open" array by mosShowHFMenu (?).
To fix this, I ran a quick query in mosShowHFMenu to grab the parent ItemID, and sent that along to mosGetMenuLink.
right underneath the existing query stuff in mosShowHFMenu I added:
Code:
$sql = "SELECT m.*"
. "\n FROM #__menu AS m"
. "\n WHERE id = $Itemid"
. "\n AND published = 1"
;
$database->setQuery( $sql );
$parent = $database->loadObjectList( 'id' );
$open = array($parent[$Itemid]->parent);
and then modified the call to mosGetMenuLink
Code:
$links = array();
foreach ($rows as $row) {
$links[] = mosGetMenuLink( $row, 0, $params, $open );
}
this works (gives me correct highlighting in my menu structure), I hope this can help someone else too. Hasn't broken any of my other HF menus (though i only have one other...

)
This isn't recursive though - there is recursive code in the other menu functions (not sure why HF doesn't handle this?? i must be missing something here.), so look at that if you need recursive abilities.
Chris H