Hi there,

Is it possible to get the order of the menus in the Sitemap display the same as the left sided navigation weightings?

At present they are ordered by the name of the menu blocks.

Many thanks!


#20 put_in_template_modified.txt5.51 KBmairav
Members fund testing for the Drupal project. Drupal Association Learn more


seanbfuller’s picture

Agreed. This would be a great feature.

Tony Sharpe’s picture

Agreed - I also need this. At present my main navigation is displayed below some secondary low-level menus

echoz’s picture

Preferably a way to order menus outside of the navigation menu. Custom menu blocks are ordered alphabetically, and sadly this is a show stopper for my needs.

marcvangend’s picture

+1 for this feature.

Quick workaround: you can manually change the order by editing the variable stored in the database. I use the devel module to display the 'execute php' block to run the code.

Step 1:
To get the current variable, I execute (without the php tags):

var_export(variable_get('site_map_show_menus_nl', array()));

If you use the locale module, change the "_nl" part to your own language code. If you don't use the locale module, just use "site_map_show_menus".
The result will look something like this:

array (
  'primary-links' => 'primary-links',
  'secondary-links' => 'secondary-links',

Step 2:
Copy the result to a text editor and change the order. For instance:

array (
  'secondary-links' => 'secondary-links',
  'primary-links' => 'primary-links',

Step 3:
Write the new variable to your database. Execute the following code in the execute php block:

variable_set('site_map_show_menus_nl', array (
  'secondary-links' => 'secondary-links',
  'primary-links' => 'primary-links',

That's it.
Disclaimer: Use at your own risk. Changes will be lost when you submit the form at admin/settings/sitemap again.

Tony Sharpe’s picture

Thanks - I'll give it a go.

xurizaemon’s picture

Category: support » feature

Changing to feature request - would be great if this was added, along with configurable order of taxonomies if displayed.

Perhaps allowing configurable order of all items (ie menu 1, taxo 3, menu 2, rss feeds, taxo 2), but I suspect if you get that far you probably will end up using views / panels.

http://drupal.org/node/146710 is a duplicate of this (from 2007) but I've marked that one duplicate because this one actually has a useful workaround for people to see.

ghing’s picture

For a work project project, I had to create a custom module that adds additional functionality to including menu in the site map via the Site Map module.

This additional functionality includes:

* The ability to include menus only to a certain depth.
* The ability to exclude arbitrary menu items from the site map.
* The ability to order the menu items in the site map.
* Increased theming control of the the site map menu.

If you're interested, you can get the module from http://github.com/ghing/menu_site_map/tree/master.

To use this module, select no menus in the regular Site Map configuration. Then configure the menus at /admin/settings/sitemap/menu_sitemap. You can also exclude menu items at /admin/settings/sitemap/menu_sitemap/select_links.

Let me know if it's useful. My hope is that this functionality can be merged into the site map module.

mairav’s picture

@ghing I installed your module, but when I hit the "Save configuration" button I get
Fatal error: Call to undefined function dfb() in /var/www/html/sites/all/modules/ghing-menu_site_map-2d3d3ef68b4181d997a2c91aa2e144a8ecee1528/menu_site_map.admin.inc on line 120

And when I try to go to /admin/settings/sitemap/menu_sitemap/select_links it says a 404 error.

Any tips? Your ideas are what I was looking for to do with my sitemap.

mairav’s picture

Related to #8, I edited your menu_site_map.admin.inc file and commented the dfb function and the error stopped showing.
About the place to select links, It didnt' recognize the link if i didn't use the www in the domain. I entered through the menu item and it worked.
One other problem I have is that each menú item is inside an h2 tag which is no write, it should be in a nested ul or ol depending on the levels I give to my menú at the select links page. I'm looking for a way to solve this so it can be valid and semantic xhtml.

The correct structure should be:

   <li>Item 1</li>
   <li>Item 2</li>
   <li>Item 3
         <li>SubItem 1</li>
         <li>SubItem 1</li>
         <li>SubItem 1</li>
   <li>Item 4</li>
   <li>Item 5</li>
   <li>Item 6</li>
   <li>Item 7</li>

mairav’s picture

Related to #8, I made some changes, and now I have ul a li but I have some problems with the correct nesting or the items.
Besides, I have a multilanguage site, and the items name are not being translated. The links are ok, depending on the language.

ghing’s picture

Re #8:

Sorry that was an errant FirePHP debugging statement. This is now fixed in the head of the repository at http://github.com/ghing/menu_site_map/tree/master

ghing’s picture

Re #9:

I know that the HTML is a little strange (the lists are not nested), but writing the HTML in the way it is implemented just made it easier to style the output as required by the project. The important thing, and one of the improvement of the Site Map module's menu handling was that the rending of the menu is implemented in a themable function theme_menu_site_map_menu_tree(). You can copy this code into your theme's template.php and rename it YOUR_THEME_NAME_menu_site_map_menu_tree and modify the output code as you see fit.

I think you're right that it would make more sense to have the nested lists as the default. If you send me your modifications, I can merge them in. You can mail them to me at ghing [at] crl.edu, attach them as a patch, or use github directly (http://help.github.com/forking/).

mairav’s picture


First, I'm not a programer, I just understand some PHP and started making some attemps to fix it.

I have to major problems until now:

1) If I have items inside an element (it doesn't have the leaf class), it hides the inside items, but it doesn't hide the ul container.
2) I can't make until now that the new items of a list appear inside the correct place. For example, if an item has a child, the complete


goes inside the parent <li></li> after the parent name.

Some tip about the themable function?

anil614sagar’s picture

+1 subscribing

hass’s picture

-1 on this. Sounds like bad usability. Without reordering - the menu is the same and this is much better (recognition factor).

mairav’s picture

@ghing could you see something of the code I sent you?
@hass, the original module doesn't allow to include things that are not in the menu. With ghing module, you can other things, that may be important in a sitemap, and that should be placed somewhere between the menú items, that's why the ordering is important.

hass’s picture

There is no ghing and no menu_site_map module. And here is no patch...

mairav’s picture

@frjo and @hass, is there any way you can add to the original module some of the functions that @ghing added in the module he made, and that he mentioned in #307215-7: Order of the menus in the sitemap, at least as a submodule that can be optionally enable?

Something like that would be really usefull for many users.

For example, I have several pages of my site that are not accesible through any menu, but should be shown in a sitemap to help people.

Site map is the best module to make site maps, and it would be even better with this function. I know you may consider it's not the way to make a sitemap, but you should give the users the option to make another things with a sitemap, like adding links to certain nodes, so you'll gain a lot of users for this module.

I hope you can consider adding this. Sinceresly thanks. Maira.

ghing’s picture

I have updated my module and it can be checked out at http://github.com/ghing/menu_site_map/

An example of using its theme functions to produce menus with nested ul/li tags (like the Site Map default) is available at http://wiki.github.com/ghing/menu_site_map/theming-example

Re #17: This module is not yet hosted in drupal.org CVS because I was hoping that some of the changes could just get merged into the regular Site Map module rather than creating yet another module. If there is any interest in this, I am happy to help with the merge. Consider the module hosted on git hub as a proof of concept. If the developers of this module want to keep the menu output as-is, please let me know and I can try to add this as a separate project on drupal.org


mairav’s picture

Thee theming example that @ghing shows in http://wiki.github.com/ghing/menu_site_map/theming-example doesn't order the source code.
I made some changes to it to show a correct nested source code. Remember to change the afd word ( my theme name) for yours.
This code has to be added to the template.php file in the theme folder.

Bartezz’s picture

Works great! Thanks!

ghing’s picture

I have now gotten my Menu Site Map module listed as a project on drupal.org. Anyone looking for this functionality might want to check it out at http://drupal.org/project/menu_site_map


neilnz’s picture

I found another hacky fix to this. If you rename your menus so alphabetically they're correct, eg "A Menu 1", "B Menu 2", then they will sort correctly on the sitemap config page. When you save it, they'll be in the right order. You can then rename the menus back and they'll still stick in the same order. The only issue is if you re-save the sitemap page subsequently, they'll revert again.

This really should be fixed...

jberg1’s picture

I would like to see the ability to order the menus from the Sitemap Configuration page. Also include static pages that are not listed in any menus.

tanjerine’s picture

+1 on the ordering feature

markpetherbridge’s picture

Is this only to create an XML sitemap?

Sheffield Website Design | Follow me on: Twitter - Facebook

varnent’s picture

+1 for this feature - although more for the ability to place books below menus than to change the order of menus.

imperial_dalek’s picture

Hi there,

I have created an update to the Site Map module that allows you to order menus that are displayed in Site Map.

See: http://drupal.org/node/1529708#comment-5860846 for details and download

enjoy !



bpwt’s picture

gr8 it works like a charm (but the variable I used "site_map_show_menus").



mortona2k’s picture

Version: 6.x-1.x-dev » 8.x-1.x-dev
Issue summary: View changes

I'm bumping up to 8.x since this is still an issue. My client is confused since they set the order, but it appears to reset when they click save.

The sitemap does work, however. It should be a simple change to list the menus in order of weight in the admin screen.