A big part of my site uses Wacko Wiki as its engine so when I implemented Google Sitemap support for the other half it only seemed fitting that I do the same for the wiki. I didn’t see any available plugins on the Wacko homepage so I wrote my own function to handle this.
There are only two changes that need to be made so most Wacko Wiki users can implement this.
In the wacko.php file look for the SavePage function. Near the end add the highlighted line after the non highlighted one:
Then search for the WriteRecentChangesXML function. After that function add this new one and your all done:
$xml = "<?xml version="1.0" encoding="windows-1251"?>n";
$xml .= "<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">n";
if ($pages = $this->LoadRecentlyChanged())
foreach ($pages as $i => $page)
if ($this->config["hide_locked"]) $access =$this->HasAccess("read",$page["tag"],"guest@wacko" );
if ($access && ($count < 100))
$xml .= "<url>n";
$xml .= "<loc>".$this->href("", $page["tag"])."</loc>n";
$xml .= "<lastmod>". substr($page["time"], 0, 10) ."</lastmod>n";
$daysSinceLastChanged = floor((time() - strtotime(substr($page["time"], 0, 10)))/86400);
if($daysSinceLastChanged < 30)
$xml .= "<changefreq>daily</changefreq>n";
else if($daysSinceLastChanged < 60)
$xml .= "<changefreq>monthly</changefreq>n";
$xml .= "<changefreq>yearly</changefreq>n";
// The only thing I'm not sure about how to handle dynamically...
$xml .= "<priority>0.8</priority>n";
$xml .= "</url>n";
$xml .= "</urlset>n";
$filename = "xml/sitemap-wackowiki.xml";
$fp = @fopen($filename, "w" );
As default I have set it to generate the XML file using the last 100 modified pages although that can be easily altered. The change frequency is set by checking the number of days since each page was last changed. Depending on the outcome it can be “daily”, “monthly” or “yearly”. Just remember to set the correct write permissions on the XML folder. If your “recent_changes” XML is getting generated correctly then you know the permissions are already setup ok.
The path to the file will be:
substituting where appropriate obviously.
So once you’ve created your Google account and submitted the link to the xml file your good to go. You shouldn’t really have to do anything after this point except login to check your stats every now and then. Google will keep checking for updated files every now and then so you don’t even have to resubmit it manually. How good is that?
Edit: So good its become an official hack!