Copied to clipboard

Flag this post as spam?

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


  • Bruce Canino 21 posts 42 karma points
    Apr 20, 2011 @ 19:59
    Bruce Canino
    0

    SiteMap Help

    I was thinking I was begining to understand Xslt but maybe I not.

    Using Umbraco 4.7

    I modifed the SiteMap Macro to display the data in a way I wanted.

    <?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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

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

    <xsl:template match="/">
    <div id="sitemap">
    <xsl:call-template name="drawNodes">  
    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/>  
    </xsl:call-template>
    </div>
    </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)">
    <ul><xsl:for-each select="$parent/* [@isDoc  and @level &lt;= $maxLevelForSitemap]">
    <li>  
    <a href="{umbraco.library:NiceUrl(@id)}">
      <xsl:value-of select="@nodeName"/></a>
    <xsl:if test="count(./* [@isDoc  and @level &lt;= $maxLevelForSitemap]) &gt; 0">   
    <xsl:call-template name="drawNodes">    
    <xsl:with-param name="parent" select="."/>    
    </xsl:call-template>  
    </xsl:if>
    </li>
    </xsl:for-each>
    </ul>
    </xsl:if>
    </xsl:template>
    </xsl:stylesheet>

    which works fine. but I don't want to use the nodeName but the pageTitle from the metatab and I know the field because the following macro in the master template put the pagetitle on the pages

    <title><umbraco:Item field="Pagetitle" useIfEmpty="pageTitle" runat="server"></umbraco:Item></title>

    but when I try to use it in the xlst codeI never get anything to display

    <xsl:value-of select="@nodeName"/></a>.I have tried replacing @nodeName with  @PageTitle, @pageTitle,  @data [@alias = 'pageTitle'] and just about anything else I seen in this forum, but nothing seems to work.

    any clues?

    Bruce

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 20, 2011 @ 20:52
    Tom Fulton
    0

    Hi Bruce,

    You were close...try just:  Pagetitle  (without the @)

    Ex:

     <xsl:value-of select="Pagetitle"/>

    the @ signs are for attributes of a node (@id, @nodeName), for example <Textpage id="1111" nodeName="test" ...

    Any custom properties are stored as elements, for example <Textpage id="1111" nodeName="test" ..><Pagetitle>your page title</Pagetitle></Textpage>

    On a side note, if you wanted to still use the nodeName as a fallback, you could do:

    <xsl:choose>
    <xsl:when test="Pagetitle != ''">
    <xsl:value-of select="Pagetitle"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="@nodeName"/>
    </xsl:otherwise>
    </xsl:choose>

    Hope this helps,
    Tom

  • Bruce Canino 21 posts 42 karma points
    Apr 20, 2011 @ 21:35
    Bruce Canino
    0

    Tom,

    Thank you very much.

    Thank you for the explantion about the @,

    Bruce

Please Sign in or register to post replies

Write your reply to:

Draft