Copied to clipboard

Flag this post as spam?

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


  • Stephen 204 posts 226 karma points
    Aug 31, 2011 @ 12:45
    Stephen
    0

    Display on level and parent alias

    Hi All,

    I have a subnav that dsiplays when its level 2 as show below..works well

    <?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="xml" omit-xml-declaration="yes"/>

        <xsl:param name="currentPage"/>

        <xsl:template match="/">
          <xsl:if test="$currentPage/parent::* [@level >= 2]" >
            <xsl:variable name="parentNode" select="$currentPage/parent::* [@isDoc]"/>
              <a href="{umbraco.library:NiceUrl($parentNode/@id)}">
                ...back to <xsl:value-of select="$parentNode/@nodeName"/>
            </a>
          </xsl:if>
        </xsl:template>

    </xsl:stylesheet>

     

    I  now have a requirement for displaying when level 2 but NOT when the parent node is of an alias "tmFolder" as it has not content and is only there to containt the sub pages...

    I'm using the following but not wokring..

    <?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="xml" omit-xml-declaration="yes"/>

        <xsl:param name="currentPage"/>

        <xsl:template match="/">
          <xsl:if test="$currentPage/parent::* [@level >= 2 and $currentPage/parent != 'tmFolder']" >
            <xsl:variable name="parentNode" select="$currentPage/parent::* [@isDoc]"/>
              <a href="{umbraco.library:NiceUrl($parentNode/@id)}">
                ...back to <xsl:value-of select="$parentNode/@nodeName"/>
            </a>
          </xsl:if>
        </xsl:template>

    </xsl:stylesheet>


    Thanks for listening.

    S

  • Rasmus Berntsen 213 posts 251 karma points c-trib
    Aug 31, 2011 @ 16:47
    Rasmus Berntsen
    0

    So what you're doing at the moment in your xsl:if is to test if the node below the currentpage, with the alias parent, is not equal to tmFolder. You want to look at the parent of currentpage and check that the alias of that is not tmFolder. 

    Take a look here for XPATH: http://our.umbraco.org/wiki/reference/xslt/xpath-axes-and-their-shortcuts - You'll need this to get the ancestor (parent node)

    And take a look here for how to test on node aliases: http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/no-more-@nodetypealias - You'll need this to test for the nodes alias. 

    Let me know if this is enough help or I'll try to look into it. :)

    Edit: Fixed spelling

Please Sign in or register to post replies

Write your reply to:

Draft