Drupal 6 Sitemap Block Module
Posted By jack on Jul 26 2010
This module lets you display a Drupal sytem menu as a sitemap (all links are expanded - up to 3 links deep) in a block. The block that can be dropped into any region of your theme using the standard blocks interface within Drupal.
This module was based on the footermap module (which does a similar job and has some good features) however, we found the code to be a little confusing, there were some bugs and it didn't render the menus as we would have wished. All three things meant it was unusable for us or our clients. We've spent a few days developing our own much tidier, slimmer and (in our opinion) much better version.
Using the module
- upload to your Drupal site and install
- configure it - /admin/settings/sitemapblock
- choose a region for the block - /admin/build/block
The Latest Version
Version 1.4
- Added language support - now only shows menu items that are in the current language or language independant
- Restricted use to primary-links, secondary-links and nav
- Restricted menu recurse to 3 levels
- Fixed bugs to do with dupe/disabled menu items
Version 1.5
- Added support for custom menus
Version 1.6
Version 2.0
- Direct port from drupal 7 version.
Spread The Love
Ready to rock? Get in touch for a free consultation & quote.
Get in touch
Comments
Thanks a lot for the module! Just what was needed.
Glad you found it useful!
this is exactly what i was looking for too! Although I would appreciate having, in addition to classes for first and last list entries, a class for the middle menu entries as well.
Hi - I'm working on this module right now. The plan is to have a unique class for each item e.g. item1, item2 etc. PLUS - first last and middle. I'm fixing a bug which causes disabled views menu items to show up in the list as well. Expect an update before the end of the week.
where does this module get its list of entries from? I deleted and addded some menu entries and now both the deleted and the added entries are part of the site map block module. How can I make it use only the current menu entries?
Hi Matthew, Sounds like the bug I mentioned in my previous comment. I am working on a fix for this right now... if you can hang on `til tomorrow I will post an update.
Hi all,
With 6.x-1.6 version, i modify the query in sitemap_block.module line 76
Only publish node is now showing.
replace
<code>
$result = db_query("SELECT ml.* FROM {menu_links} as ml, {menu_router} as m WHERE (m.path = ml.router_path OR ml.router_path = '') AND ml.menu_name = '%s' AND ml.depth = %d AND ml.hidden = 0 ORDER BY ml.weight ASC", $activeMenu, $count);
</code>
By
<code>
$result = db_query("SELECT ml.* FROM {menu_links} as ml, {menu_router} as m, {menu_node} as mn, {node} as n WHERE (m.path = ml.router_path OR ml.router_path = '') AND ml.menu_name = '%s' AND ml.depth = %d AND ml.hidden = 0 AND ml.mlid = mn.mlid AND mn.nid = n.nid AND n.status = 1 ORDER BY ml.weight ASC", $activeMenu, $count);
</code>
haha great! I'm glad it was useful!
Very nice module, but I think you are missing one thing.
The links should link to the url_alia's node and not directly to the node path.
Example: domain.com/about and not domain.com/node/10.
Hi Joao - good point will post an update in a day or two.
This looks like an improvement on the footermap module. Any idea on how to theme this as i would like to display at the bottom of the page using three or four columns?
Hi Dan, you should be able to style each <ul> as a "column"... the css below should get you started...
.block-sitemap_block ul { display:block; float:left; width:*enter the width of your column here in px*; }
that should get each ul floating next to each other... for more info on floats check out this link http://www.w3schools.com/css/pr_class_float.asp
I recently styled it on this site... you can copy some CSS from there if you need. http://ctfmontreal.com/
Thanks a lot !!! juste what i wanted.
Feature request. How about the ability to display more than one menu in the site map. for example I would like to display a site map to include both the primary and secondary menus. (similar to footermap module)
Hi Dan, how should this be rendered? one < ul > after the other?
Yes, that would probably work. As long as they can be styled so that they look as one. At the moment I have created a separate menu to be used as a site map and have incorporated 'Multiple Node Menu' but I think your module would be a more elegant solution if it had support for multiple menus.
Just posted a drupal 7 version of this module - http://beacon9.ca/labs/drupal-7-sitemap-block-module
Are you guys planning on contributing this back on drupal.org? Would be nice so I can get updates and whatnot through drush.
Hi Sam - Yes, we will eventually contribute this on drupal.org.
Version 2.0 is released. Its a direct port of 7.1.2 version of the module. Much cleaner code and allows us to recurse deeper into menus.
This worked for me except not all the primary links showed up or were expanded. Any idea why this would happen? Thanks!
you have to set how deep the menus should go, check out the module settings.
it's possible to disable menu items.. check none of your menu items are accidentally disabled.
hiya,
great module, but i have tio ask a (probably kind of stupid) question. I checked out your implementation on http://ctfmontreal.com/ and it looks like exactly what i'm after. But how did you get drupal to output each 'primary menu' item in its own <ul>? What am i missing here please?
Hey, drupal "nests" the <ul> elements for you when you add a new menu item as a child to an existing item.
thanks so much for the response. I may be doing something wrong here, I'm not super drupal-literate yet. In Drupal 6 my output from ur module has the entire menu in one <ul>, like this:
<ul id='sitemap_block_parent'>
<li class='first'>link1</li>
<li>link2</li>
<ul id='sitemap_block_295'>
<li class='first'>link2a</li>
<li class='last'>link2b</li>
</ul>
<li>link3</li>
<li class='last'>link4</li>
</ul>
I fiddled your code to output the following:
<ul class='first'>link1</ul>
<ul>link2
<li>link2a</li>
<li>link2b</li>
</ul>
<ul>link3</ul>
<ul>link4</ul>
which appears to be what's on ctfmontreal.com. It allows me to sstyle the <ul>'s next to each other now. if theres a better way, PLEASE let me know. I'm not sure this is valid html :(
thanks again
Phil
mmm it might be valid... not exactly standard practice though... with the right CSS, you should be able to get the menus next to each other like on ctfmontreal.com. check out the css I used on that site/feel free to copy it if you need.
This is a great module...the only thing I'm having trouble with is the recursive settings.
I have a menu that is two levels deep. Only two of the first level links are drop downs. Oddly enough, when I set the sitemap module recursive limit to "2", it doesn't show all my menu links. However, when I set the limit to "3" then all of them show.
The settings for my second level links are the same. Is this how the recursive limit setting is supposed to work, or is there a reason why I can't get all of my second level links to show when the recursive limit is set to "2"?
I think it's a great module. Why don't publish it on drupal.org ? Drupal modules lacks in modules for sitemaps and your module fits perfectly. And so, you'll get some advertising :) (you can write on module presentation that is supported by you, with link )
Good luck!