Cat Sitemap
Cat Sitemap
My class for make sitemap.
Work fine on my sites and have option for use crontab for create the sitemap.
Click HERE for see the code of this class
This is an example of the class uses:
< ?php
// Set the path to webserver root
$path = $_SERVER['DOCUMENT_ROOT'].'/';
// Set url to webserver root
$url = 'http://'.$_SERVER['HTTP_HOST'].'/';
// include library
require(cat-sitemap.inc.php');
// inizialize the sitemap class
$map = new Cat_Sitemap($url.'/', $path, array('debug'=>true,'log_path'=>$path.'write/'));
// Make query
$sql = " SELECT page_name, url, lastmodify FROM my_database_table".
" WHERE 1 ORDER BY lastmodify DESC";
if (!$results = mysql_query($sql)) {
// No results ...
exit;
}
while($val = mysql_fetch_assoc($results)) {
// Here you need to set frequency and all datas for the url
$map->add_item($val->url, 'daily', 1, $val->lastmodify);
//$map->add_item($val->url, 'weekly', 0.6, $val->lastmodify);
//$map->add_item($val->url, 'monthly', 0.8, $val->lastmodify);
}
// Create sitemap
if (!$map->create()) {
trigger_error('Can create the sitemap !!', E_USER_WARNING);
}
// Print the log for this sitemap
echo $map->get_logDatas();
// Destroy the class
$map->__destruct();
?>

Hits : 10
