Skip navigation.

Undefined

talk talk about Umbraco, .NET

Google Sitemap

, ,

I actually just adjusted the standard sitemap xslt :smile: -- you should install umbraco utilities for this, to change the mime-type or use <xsl:value-of select="umbraco.library:ChangeContentType('text/xml')"/> in umbraco v4 (thanks to bootnumlock) -- don't forget to change the url in the xslt :smile: --

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<!-- update this variable on how deep your site map should be -->
<xsl:variable name="maxLevelForSitemap" select="10"/>

<xsl:template match="/">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<xsl:call-template name="drawNodes">  
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node [@level=1]"/>  
</xsl:call-template>
</urlset>
</xsl:template>

<xsl:template name="drawNodes">
<xsl:param name="parent"/> 
<xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
<xsl:for-each select="$parent/node [string(./data [@alias='umbracoNaviHide']) != '1' and @level <= $maxLevelForSitemap]"> 
<url xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<loc>http://www.corazine.com<xsl:value-of select="umbraco.library:NiceUrl(@id)"/></loc>
<lastmod><xsl:value-of select="umbraco.library:FormatDateTime(@updateDate, 'yyyy-MM-dd')"/></lastmod>
<changefreq>weekly</changefreq>
</url>
<xsl:if test="count(./node [string(./data [@alias='umbracoNaviHide']) != '1' and @level <= $maxLevelForSitemap]) > 0">   
<xsl:call-template name="drawNodes">    
<xsl:with-param name="parent" select="."/>    
</xsl:call-template>  
</xsl:if> 
</xsl:for-each>
</xsl:if>
</xsl:template>
</xsl:stylesheet>


and the template:

<%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
<umbraco:Macro ContentType="text/xml" Alias="uuContentType" runat="server"></umbraco:Macro><?xml version="1.0" encoding="UTF-8"?><umbraco:Macro Alias="SitemapXml" runat="server"></umbraco:Macro>
</asp:Content>


et voila :smile:

umbraco BaseUmbraco modules for Runway

Comments

Anonymous 30. December 2008, 22:56

Ruben Verborgh writes:

Maybe a weird question... but if you check your RSS output, don't you see UTF-16 on top instead of UTF-8?

Anonymous 30. December 2008, 23:02

Ruben Verborgh writes:

... or none at all or course, in which case you'd need to add that for a valid sitemap. But I have this feeling that omit-xml-declaration="no" would produce strange results. Does it validate?

Anonymous 31. December 2008, 01:17

bootnumlock writes:

I think i also see in v4 that change content type is built into umbraco.library here is a snippet from the rss template that came with RC4


Gerty Engrie 31. December 2008, 10:31

@Ruben yes, i see utf 16, but hey, it works :D
the omit-xml-declaration="no" does idd produce non-valid things...

@bootnumlock Thanks for the tip!

Anonymous 2. January 2009, 10:38

Ruben Verborgh writes:

But then your sitemap is invalid. Have had parsing problems with that. (http://www.sitemaps.org/protocol.php)

The trick is to either add the XML declaration in your template, or using an to render it inside XSLT.

Gerty Engrie 2. January 2009, 13:50

Tried both, but couldn't save the xslt if I put the xml declaration in the xslt:text. Google considers it valid... ehr lol view source: <?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> (http://www.corazine.com/?alttemplate=sitemapxml)

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies