
menu links pointing to different servers isnt allowed..
still great script
Code: Select all
if (!$onecontent->Active())
{
continue;
}
//MODIF - ADDED
if (!$onecontent->ShowInMenu())
{
continue;
}
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
'. "\n";
*/
echo '<urlset>' . "\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;
}
$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";
?>
Code: Select all
echo '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
'. "\n";
Code: Select all
XML Parsing Error: no element found
Location: http://www.uvc-cog.org.uk/sitemap.php
Line Number 110, Column 1:
No, it actually works for me - "Sitemap status: OK". Did you try the code I attached? It differs from the one you pasted in that the xml namespaces in the have been commented back in.HuttonIT wrote: Yes it works but have you noticed that Google keeps showing it as "Unsupported file format". This may be fine but if it is not supported then it will not be searched by Google....
Code: Select all
$config['auto_alias_content'] = true;
Code: Select all
$config['assume_mod_rewrite'] = true;
Code: Select all
<?php
require_once(dirname(__FILE__)."/include.php");
global $gCms;
$db =$gCms->GetDb();
$dbresult = $db->Execute("SELECT c.content_id,c.content_alias,c.type,c.modified_date,c.show_in_menu FROM ".cms_db_prefix()."content c INNER JOIN ".cms_db_prefix()."content_props p ON p.content_id = c.content_id WHERE (c.content_id = p.content_id AND c.active = 1 AND c.type='content' AND c.show_in_menu =1)");
$out='<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">'."\n";
if ($dbresult)
{
while ($dbr = $dbresult->FetchRow())
{
$d = explode(" ", $dbr['modified_date']);
$date = $d[0];
$time = $d[1];
$datetime = implode("T",$d);
$out
.="<url><loc>".$config['root_url']."/".$dbr['content_alias'].$config['page_extension']."</loc><lastmod>"
.$datetime."+00:00</lastmod><priority>0.5</priority></url>"."\n";
}
}
$out .="</urlset>";
header("Content-Type: application/xml");
echo $out;
?>