How to... > Menu
WX5 automatically generates a sitemap in the file 'imsitemap.html'. This works great when you have got only one site. But when a large site which you have split into several sub-sites then each sub-site will have it's own sitemap, but there is no general sitemap which shows all the pages of all your subsites.
I am building a site which has nine of those sub sites which all have a vertical menu. I have added a horizontal menu using this technique to link all sites together and I wanted a general sitemap. I have created some PHP-code to generate this sitemap on request, using the sitemaps which are generated by WX5. It works fine. See www.schotlandopmaat.nl and then select the menu item 'Sitemap (hele site)' to see the result (sorry, only in Dutch. We are working on a translation in English...
To use this php-code just create a new page. Add one html-block and copy/paste the following code into this block.. Don't forget to set the desired height of the html-block.
<?php
function getSitemap($foldername) {
$fn=$foldername ."/imsitemap.html";
if (file_exists($fn)) {
$fh = fopen($fn, 'r');
$str = fread($fh, filesize($fn));
fclose($fh);
$part=strstr($str, "<div id=\"imMap\" class=\"imDefText\">");
$i=stripos($part,"</div>");
$part=substr($part,0,$i+6);
$strPattern = "/href=\"/";
$strSubst = "href=\"" . $foldername . "/";
$part=preg_replace($strPattern, $strSubst, $part);
return $part;
}
else {
return false;
}
}
// main part...
echo '<div style="text-align: left">';
$sm=getSitemap(".");
echo "<H2>First Title</H2>" . $sm;
$sm=getSitemap("../subsite2");
echo "<H2>Second Title</H2>" . $sm;
$sm=getSitemap("../subsite3");
echo "<H2>Third Title</H2>" . $sm;
// add al your subsites...
echo '</div>';
?>
Change the following lines to suit your site.
$sm=getSitemap(".");
echo "<H2>First Title</H2>" . $sm;
$sm=getSitemap("../subsite2");
echo "<H2>Second Title</H2>" . $sm;
Use the paths relative to the home page of your main site. For each sub-site add a separate two-line block.
Next, go to the Map Creation dialog, select (not open!) the newly created page and select the Page Properties, which is the last icon in the toolbar.
Select the 'Advanced' tab, set the File Name Format to 'PHP' and copy/paste the following code in the code to add to the page header.
<link rel="stylesheet" type="text/css" href="res/imsitemap.css" media="screen, print" />
<style>
#imMap {
min-height: 0pt;
}
</style>
This code only works when you publish it to a web server which has PHP capabilities. If you are not sure, then ask your provider.
Sub-Menu: