Because of the way the code page is evaluated, you cannot simply cut'n'paste ("<?php" tags are not permitted, you have to echo out html code). But here is working code for the simplest imaginable sitemap. Just create a page (or section) "Code" and paste it.
function site_map($parent) {
global $database;
global $page_id;
// Query pages
$query_menu = $database->query("SELECT page_id,menu_title,link,target,level FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC");
// Check if there are any pages to show
if($query_menu->numRows() > 0) {
// Loop through pages
while($page = $query_menu->fetchRow()) {
$pad=$page['level']*8;
echo '<li style="padding-left: '.$pad.'px;';
if($page['level'] == 0) echo 'font-weight: bold;';
echo '"><a href="'.page_link($page['link']).'" target="'.$page['target'].'">';
echo $page['menu_title'];
echo '</a></li>';
site_map($page['page_id']);
}
}
}
echo '<ul style="list-style: none;">';
site_map(0);
echo '</ul>';
Maybe this would be something for our scripts collection.
[EDIT: I changed the name of the function because of possible conflicts with the menu code!]