Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Site Map Module in any template


Reply


4 Posts   1406 Views

Avatar
Graphicator

Community Member, 62 Posts

13 July 2010 at 12:28am

About a month ago, I noticed that sitemapmodule needed to be fixed for version 2.4 support. I'm glad they released a new version that supports 2.4

I was wondering how to get SiteMap Module to display as a widget or somewhere in the sidebar. Or if there was a way to call $SiteMap?

I also wanted to know if I could use $SiteMap anywhere in the template, as a default style, instead of the slick style, but keep the intended sitemap page as the slick style.

Avatar
TotalNet

Community Member, 181 Posts

13 July 2010 at 10:33am

Not in a literal sense AFAIK
However, the functionality is quite easy to replicate.

One way would be to use existing page controls and build your own in a template and include it just like you can with Navigation.ss
Another way would be to add a method to your page class and re-use the code from Sitemap, either by copying code directly or calling SiteMapModule::Content() perhaps

Essentially it's all an unordered list with a style sheet and some JavaSctipt to make it look nice, all of which is right there in the Sitemap module, you can probably do the whole thing with copy/paste.

Rich

Avatar
DesignCity

38 Posts

15 July 2010 at 8:55pm

Edited: 15/07/2010 9:01pm

Greg - thanks for the email pointing to this forum post, otherwise I'd have never seen it!

As Rich notes, the module hasn't really been designed to do that, but the functionality is easy to replicate.

A couple of thoughts, firstly http://doc.silverstripe.org/tutorial:site-map has similar (older) code as the module, so you could copy the two functions SiteMap() and makeList($pages) onto your Page_Controller and access them using $SiteMap on any page. Add in the css that the tutorial describes and you're mostly there.

If you're keen to have the Site Map Module working across the site, you can with a few changes.

Firstly, open sitemapmodule/code/SiteMapModule.php and on lines 118 and 160, replace

$this->

with

SiteMapModule::

Secondly, create a new function on Page_Controller as follows:

   public function ShowSiteMapHere() {
      Requirements::javascript("sitemapmodule/javascript/sitemap-default.js");
      Requirements::css("sitemapmodule/css/sitemap-default.css");
      return SiteMapModule::Content();
   }

And from there you will be able to use $ShowSiteMapHere in your Page templates to show the site map. It won't affect your site map page at all, and you can swap the theme by changing the JS and CSS above to sitemap-slickmap.js and sitemap-slickmap.css respectively if you wanted.

If there's a lot of community interest we could incorporate it into the module, but truthfully, I can't image there would be!

Hope this helps :)

Design City

Avatar
bunheng

Community Member, 78 Posts

7 November 2010 at 5:26am

Hi,

I just created sitemap it working fine my local machine, but it show only page in parent position and page which I chose to display in menus, is there any possible way to display all pages in sitemap.

Thanks.
Bunheng