google sitemap by category ( part of menu )

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
hadion
Forum Members
Forum Members
Posts: 17
Joined: Thu Apr 26, 2007 10:02 am

google sitemap by category ( part of menu )

Post by hadion »

I created a multiple domain CMS MS, where second level menu items are the parent of an seperate domain.
Anybody knows how to parse an google sitemap from a specific menu item, instead of the whole website?

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 $

# Google Sitemap Plugin
# Developers: 
# 	Stefan Noll (Stefan.Noll@web.de)
#	owl666
#	fredt
# 	PePiPoo


// Configuration:

	//setting time-zone statically
define("TZD", "+01:00");
	
// hides items which are not shown in the mnu	
define("HIDE_NONMENITEMS", false);



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";

	global $gCms;
	$contentops =& $gCms->GetContentOperations();
	$allcontent = $contentops->GetAllContent(false);

	$maxdepth = 1;
	
	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($onecontent->DefaultContent())
		 {
			$rel = 1;
		 }
		
		if (!$onecontent->Active())
		{
			continue;
		}

		if ($onecontent->Type() == 'separator')
		{
			continue;
		}

		if ($onecontent->Type() == 'sectionheader')
		{
			continue;
		}
		
		if (!$onecontent->ShowInMenu() && HIDE_NONMENITEMS) 
		{
			continue;
		}
		// Mod by PePiPoo
		if ( strpos($onecontent->GetURL(), $gCms->config['root_url'] ) === false )
		{
		continue;
		}
		
		$date = $onecontent->mModifiedDate;
		
		$googledate = str_replace(" ", "T", $date) . TZD; 
		
				
		echo ' <url> ' . "\n";

		echo ' <loc>' . $onecontent->GetURL()  . '</loc>'. "\n";
		echo ' <lastmod>' . $googledate . '</lastmod>'. "\n";
		echo ' <priority>' . $rel . '</priority>'. "\n";
		
		// Perhaps: generate a changefreq param of $onconent->Cachable()			
		
		echo ' </url> '. "\n";
	}	

echo '  </urlset>'. "\n";
	
?>

Post Reply

Return to “Developers Discussion”