Hi, I've made a code to automatically generate a google sitemap in websitebaker.
function sitemap_rewrite()
{
$contenu_sitemap = '' ;
$saut_ligne = chr(13) . chr(10) ;
// ecrit le fichier sitemap
$contenu_sitemap .= '<?xml version="1.0" encoding="UTF-8" ?>' . $saut_ligne ;
$contenu_sitemap .= '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">' . $saut_ligne ;
// lit le fichier sitemap_template
$f_sitemap_template = WB_PATH . '/sitemap_template' ;
if (file_exists($f_sitemap_template))
{
$tableau = file($f_sitemap_template);
while(list($cle,$val) = each($tableau)) {
$contenu_sitemap .= $val . $saut_ligne ;
}
}
$f_sitemap = WB_PATH . '/sitemap.xml' ;
$fichier_sitemap = fopen($f_sitemap,"w");
$database = new database();
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE visibility = 'public'";
//Ecriture des urls
$get_pages = $database->query($query);
// Insert values into main page list
if($get_pages->numRows() > 0) {
while($page = $get_pages->fetchRow()) {
$contenu_sitemap .= '<url>' . $saut_ligne ;
$contenu_sitemap .= '<loc>' . WB_URL .PAGES_DIRECTORY.$page['link'].PAGE_EXTENSION . '</loc>' . $saut_ligne ;
$contenu_sitemap .= '</url>' . $saut_ligne;
}
}
$contenu_sitemap .= '</urlset>' . $saut_ligne ;
fwrite($fichier_sitemap,$contenu_sitemap);
change_mode($fichier_sitemap);
fclose($fichier_sitemap);
}
To use it, you just need to call the function in /admin/pages/settings2.php at line 319 (just after the function fix_page_trail) like this and everywhere you think that it can be useful to modify the google sitemap :
$obj_wb = new wb() ;
$obj_wb->sitemap_rewrite();
Hope it will help