Copied to clipboard

Flag this post as spam?

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


  • Sean 141 posts 179 karma points
    Apr 25, 2011 @ 05:19
    Sean
    0

    unable to show nodes when at lower levels

    Hi There,

    I'm wanting to show all of the nodes that have the property showAsQuickLink. So far I can get the nodes I need at the root or homepage level, however as soon as I get into the other pages it soes not return anything.

    Can someone please help me out with the syntax please?

    Thanks in advance.

    <?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"/>
       <xsl:variable name="parent" select="$currentPage/*" />   
      <xsl:template match="/">
        <xsl:variable name="maxLevel" select="4"/>
        <ul>
          <xsl:for-each select="$parent/* [@isDoc and string(showAsQuickLink) = '1']">
            <li>
              <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
              </a>
            </li>
          </xsl:for-each>
        </ul>
      </xsl:template>
    </xsl:stylesheet>

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 25, 2011 @ 05:34
    Tom Fulton
    1

    Hi,

    The problem appears to be that you are selecting all nodes under the current page, rather than all nodes under the root/home page.

    Try changing the "$parent" variable to this.  This will cause the loop to check all nodes under the root page, no matter which page you are on

    <xsl:variable name="parent" select="$currentPage/ancestor-or-self::* [@level = 1]/*" />   

    Note if you have multiple level one nodes you will probably want to use this instead to start from the content root

    <xsl:variable name="parent" select="$currentPage/ancestor::root/*" />   

    Hope this helps,
    Tom

  • Sean 141 posts 179 karma points
    Apr 25, 2011 @ 05:49
    Sean
    0

    Hi Tom,

    this one worked. Thanks very much.

    <xsl:variable name="parent" select="$currentPage/ancestor-or-self::* [@level = 1]/*" />   
Please Sign in or register to post replies

Write your reply to:

Draft