Copied to clipboard

Flag this post as spam?

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


  • aaronb 97 posts 116 karma points
    May 07, 2011 @ 01:44
    aaronb
    0

    multiple and in for-each loop? Syntax help

    I'm trying to get a 'related products' macro to work. It's shown on a product detail page, and lists out a small selection of other products in the same category, in a random order. It's all working except for trying to filter so it won't show the product you're currently viewing in the related products.

    I think my issue is in the test I'm trying to do in the for-each loop -

    This works:

    <xsl:for-each select="$currentPage/ancestor::*/* [ string(umbracoNaviHide) != '1' and
    name() = 'Product' ]  ">

    But trying to add a test for 'not including the current page' this doesn't return any nodes:

    <xsl:for-each select="$currentPage/ancestor::*/* [ string(umbracoNaviHide) != '1' and
    name() = 'Product' and @id != current()/@id]  ">

    If anyone could point out where I'm going wrong with this I'd really appreciate it.

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    May 07, 2011 @ 08:09
    Chriztian Steinmeier
    0

    Hi aaronb,

    Try something like this:

    <xsl:for-each select="$currentPage/ancestor::*/[@isDoc][not(umbracoNaviHide = 1)][not(self::Product)][not(@id = $currentPage/@id)]">
        <!-- do stuff -->
    </xsl:for-each>

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft