Oct
18
2008

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();
?>
download
Size: 8.78 KB
Hits : 11

Share and Enjoy:
  • Facebook
  • del.icio.us
  • Twitter
  • Google Bookmarks
  • Digg
  • Technorati
  • MySpace
  • Live
  • BlinkList
  • Add to favorites
  • email
  • RSS
  • Mixx
  • Bitacoras.com
  • blogmarks
  • Blogosphere News
  • Blogplay
  • connotea
  • Current
  • Diggita
  • Diigo
  • DZone
  • eKudos
  • Internetmedia
  • LinkedIn
  • MSN Reporter
  • Reddit
  • Scoopeo
  • Segnalo
  • Slashdot
  • Socialogs
  • Sphinn
Written by Davide in: Library,php | Tags: , ,

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

Theme: TheBuckmaker.com Magazine Style Templates