Copied to clipboard

Flag this post as spam?

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


  • Roger Hughes 55 posts 88 karma points
    Oct 14, 2009 @ 13:06
    Roger Hughes
    0

    Filtering not working in XSLT

    I have created the XSLT for a testimonials area that needs to display different testimonials depending on which area of the site you are in. This is filtered by a testCategory. I can only get it working on my homepage and not on any of the other child pages. I have checked the XSLT and it seems to be perfect. The node names are correct as per the XML – Root > Homepage > Testimonials is the path. Heres an example…

     

    <!--Start filtering for students page-->

        <xsl:if test="$currentPage[@nodeName='Students']">

           <xsl:for-each select="/root/node[@nodeName='Homepage']/node[@nodeName='Testimonials']/node[string(data [@alias='testCategory']) = 'Student']">

                <xsl:sort select="@createDate" order="descending"/>

            <h3> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </h3>

            <p> <xsl:value-of select="data [@alias = 'testimonialsSnippet']"/><br />

              <small>By: <xsl:value-of select="@creatorName"/></small> </p>

          </xsl:for-each>

        </xsl:if>

        <!--End filtering-->

    I have tried removing the filtering on the alias testCategory and I still get nothing. I think it is a problem with the root path because the hompage filtering is working:

    <!--Start filtering for homepage-->

        <xsl:if test="$currentPage[@nodeName='Homepage']">

          <xsl:for-each select="$currentPage/node[@nodeName='Testimonials']/node[string(data [@alias='umbracoNaviHide']) != '1']">

            <xsl:sort select="@createDate" order="descending"/>

            <xsl:if test="position () &lt;= $maxTest">

              <h3> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </h3>

              <p> <xsl:value-of select="data [@alias = 'testimonialsSnippet']"/><br />

                <small>By: <xsl:value-of select="@creatorName"/></small> </p>

            </xsl:if>

          </xsl:for-each>

        </xsl:if>

        <!--End filtering-->

    Please can anyone help me with this problem?

    Many thanks!

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Oct 14, 2009 @ 13:35
    Douglas Robar
    0

    Try this... (should work anywhere because of the ancestor-or-self::node going to the top-most node in the tree)

    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level = 1]/node[@nodeName='Testimonials']/node[string(data [@alias='umbracoNaviHide']) != '1']" >

    You could probably simplify it more by looking for the docType alias of an individual testimonial (note the '//'). Probably something like:

    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level = 1]//node[@nodeTypeAlias='testimonial' and string(data[@alias='umbracoNaviHide']) != '1']" >

    These were typed into the forum so there's a small chance of a typo... but you should get the idea. Shout if you have problems.

    cheers,
    doug.

     

Please Sign in or register to post replies

Write your reply to:

Draft