tsw wrote:
One FR from here too
menu links pointing to different servers isnt allowed..
still great script
I had Google complaining about this for my sitemap as well, so I added in an additional check before the point where the script writes a URL:
Code: Select all
if ( strpos($onecontent->GetURL(), $gCms->config['root_url'] ) === false )
{
continue;
}
The full version I'm using is shown below, and the sitemap it produces now validates OK with Google:
Code: Select all
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#$Id: preview.php 2148 2005-11-09 20:44:15Z wishy $
require_once(dirname(__FILE__)."/include.php");
header("Content-Type: application/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>'. "\n";
echo '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">'. "\n";
$allcontent = ContentManager::GetAllContent();
$maxdepth = 3;
foreach ($allcontent as $onecontent)
{
$depth = count(split('\.', $onecontent->Hierarchy()));
if($maxdepth < $depth)
$maxdepth = $depth;
}
foreach ($allcontent as $onecontent)
{
$depth = count(split('\.', $onecontent->Hierarchy()));
//$rel = 1 - ($depth-1) / ($maxdepth);
$rel = 0.7 / $depth;
$rel = number_format($rel, 1, '.', '');
if($oneconetn->default_content)
$rel = 1;
if (!$onecontent->Active())
{
continue;
}
if ($onecontent->Type() == 'separator')
{
continue;
}
if ($onecontent->Type() == 'sectionheader')
{
continue;
}
if ( strpos($onecontent->GetURL(), $gCms->config['root_url'] ) === false )
{
continue;
}
$date = $onecontent->mModifiedDate;
$datepart = explode(" ", $date);
$date = $datepart[0];
$time = $datepart[1];
//setting time-zone statically
$TZD = "+01:00";
$datetime = implode("T",$datepart);
$googledatetime = $datetime.$TZD;
echo ' <url> ' . "\n";
echo ' <loc>' . $onecontent->GetURL() . '</loc>'. "\n";
echo ' <lastmod>' . $googledatetime . '</lastmod>'. "\n";
echo ' <priority>' . $rel . '</priority>'. "\n";
// Perhaps: generate a changefreq param of $onconent->Cachable()
echo ' </url> '. "\n";
}
echo ' </urlset>'. "\n";
?>