Author:
arsebandit
Version:
0.5
Release Date:
21 Feb 2011
Category:
Output

Description

It is not a simple utility. It is a sitemap-page. With this code you can generate sitemap.xml to search engines. You will get all your pages and subpages. And also you will get custom articles, if you have. For custom articles also will be added lastmod field that is grabbed from article creation date.

XSLT

View Raw
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!--
	Sitemap page

	Info
		Version:	0.5
		Date:		21-02-2011
		Author:		arse.bandit
		E-mail:		info@supaweb.ru
		Website:	supaweb.ru
	
	About
		This page generates sitemap xml based on pages with subpages and custom articles.

	Parameters
		All you need is to correct your paths in apply-templates in template "sitemap" and
		in template "entry" in url/loc section.
		In sitemap datasource of custom articles you need to select System Date in Parameter Output section in left bottom.

	Usage
		copy this file into your sitemap.xsl page
-->
<xsl:output method="xml" indent="yes" omit-xml-declaration="no" />
 
<xsl:template match="/">
	<xsl:call-template name="sitemap" />
</xsl:template>
 
<xsl:template name="sitemap">
	<urlset>
		<xsl:attribute name="xmlns">http://www.sitemaps.org/schemas/sitemap/0.9</xsl:attribute>
		<xsl:apply-templates select="/data/nav/page[not(types/type = 'XML')]" mode="sitemap" />
		<xsl:call-template name="entry" mode="sitemap" >
			<xsl:with-param name="sitemapd" select="concat($ds-sitemap-portfolio, ', ')"/>
			<xsl:with-param name="i" select="1"/>
		</xsl:call-template>
	</urlset>
</xsl:template>
 
<xsl:template match="page" mode="sitemap">
	<url>
		<loc>
			<xsl:if test="types/type='index'"><xsl:value-of select="$root"/>/</xsl:if>
			<xsl:if test="not(types/type)"><xsl:value-of select="$root"/>/<xsl:value-of select="@handle"/>/</xsl:if>
		</loc>
	</url>
	<xsl:if test="page"><xsl:apply-templates select="page" mode="submenu" /></xsl:if>
</xsl:template>

<xsl:template match="page" mode="submenu">
	<url>
		<loc><xsl:value-of select="$root"/>/<xsl:value-of select="parent::node()/@handle"/>/<xsl:value-of select="@handle"/>/</loc>
	</url>
</xsl:template>

<xsl:template name="entry" mode="sitemap">
	<xsl:param name="sitemapd" />
	<xsl:param name="i"/>
	<xsl:if test="string-length(substring-after($sitemapd, ','))">
		<url>
			<loc><xsl:value-of select="$root"/>/portfolio/<xsl:value-of select="data/sitemap-portfolio/entry[$i]/group/item/@handle"/>/<xsl:value-of select="data/sitemap-portfolio/entry[$i]/link/@handle"/>/</loc>
			<lastmod>
				<xsl:value-of select="substring-before($sitemapd, ',')"/>
			</lastmod>
			<priority>1</priority>
		</url>
		<xsl:call-template name="entry" mode="sitemap" >
				<xsl:with-param name="sitemapd" select="substring-after($sitemapd, ',')"/>
				<xsl:with-param name="i" select="$i+1"/>
		</xsl:call-template>
	</xsl:if>
</xsl:template>

</xsl:stylesheet>

Discuss this XSLT Utility

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details