Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • San_ 3 posts 24 karma points
    Aug 26, 2010 @ 17:39
    San_
    0

    Umbraco 4.5 Sitemap

    Hello,

    I am very new to umbraco and  having issues generating the sitemap.

     

    Here is the site structure

    Home

      Subpage1

    subsubpage1

      Subpage2

    subsubpage2

    .....

    ....

     

    Here is the XSLT i am using

     

    <?xml version="1.0" encoding="utf-8"?>

    <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="html"/>

     

      <xsl:param name="currentPage"/>

      <xsl:variable name="maxLevelForSitemap" select="6"/>

     

      <xsl:template match="/">

        <div id="sitemap">

          <xsl:call-template name="drawNodes">

            <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::*[@level = 1]/* [string(umbracoNaviHide) != '1']"/>

          </xsl:call-template>

        </div>

      </xsl:template>

     

      <xsl:template name="drawNodes">

        <xsl:param name="parent"/>

        <ul>

          hello

          <xsl:value-of select="$parent"/>

          <xsl:for-each select="$parent/node">

            <li>

              <a href="{umbraco.library:NiceUrl(@id)}">

                <xsl:value-of select="@nodeName"/>

              </a>

              <xsl:call-template name="drawNodes">

                <xsl:with-param name="parent" select="."/>

              </xsl:call-template>

            </li>

          </xsl:for-each>

        </ul>

      </xsl:template>

    </xsl:stylesheet>

     

     

    The above xslt doesn't generate the sitemap.

    Please advice.

  • Patrik Wibron 40 posts 67 karma points
    Aug 26, 2010 @ 18:01
    Patrik Wibron
    1

    Did you create this XSLT from the umbraco backend?

    If not, go to the Developer-section and right-click on "XSLT" and choose "Create", you can select "Sitemap" and umbraco will generate a fully functional sitemap for your site (including the new XSLT-schema).

    edit: Did you render the macro somewhere in your template?

  • San_ 3 posts 24 karma points
    Aug 26, 2010 @ 18:57
    San_
    1

    Thanks for the reply Patrik.  I did render the macro in my template. I didn't look at the tool to generate the sitemap under developer section. Thanks for pointing that out.

    I have worked out the following XSLT that works fine.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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="html"/>

      <xsl:param name="currentPage"/>
      <xsl:variable name="maxLevelForSitemap" select="6"/>
      
      <xsl:template match="/">
            <div id="sitemap">
          <xsl:call-template name="drawNodes">
            <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@level = 1]"/>
          </xsl:call-template>
        </div>
      </xsl:template>

      <xsl:template name="drawNodes">
        <xsl:param name="parent"/>

        <ul>
          <xsl:for-each select="$parent/* [string(umbracoNaviHide) != '1' and @isDoc]">
            <li>
              <href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
              </a>
              <xsl:call-template name="drawNodes">
                <xsl:with-param name="parent" select="."/>
              </xsl:call-template>
            </li>
          </xsl:for-each>
        </ul>
      </xsl:template>
    </xsl:stylesheet>

     

    Thanks again for the quick reply.

  • SLL 6 posts 26 karma points
    Jun 19, 2013 @ 00:19
    SLL
    0

    Thank you, thank you, thank you!  That worked a treat (the code from 611 didn't work).

    Sai.

Please Sign in or register to post replies

Write your reply to:

Draft