Copied to clipboard

Flag this post as spam?

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


  • Ian Percival 2 posts 22 karma points
    Feb 29, 2012 @ 00:41
    Ian Percival
    0

    (n00b question) How to add a condition to for-each select object property

    Hey all,

    I am an expierenced developer but new to Umbraco this week. I would like to create a xslt macro that grabs objects but uses a property from the objects as a condition.

    I have added a property to all datatypes named "topNav" it is of type True/False

    I want to create an xslt macro that will grab all objects with that property set on it.

    Here are a few things I have tried but I am still learning the syntax:

    <xsl:for-each select="$currentPage/descendant::* [@isDoc and string(umbracoNaviHide) != '1' and string(topNav) == '1']">

    <xsl:for-each select="$currentPage/descendant::* [@isDoc and string(umbracoNaviHide) != '1' and string(topNav) == 'True']">

    <xsl:for-each select="$currentPage/descendant::* [@isDoc and string(umbracoNaviHide) != '1' and $topNav]">

    Can anyone point me in the right direction?

    Thanks in advance.

  • Ian Percival 2 posts 22 karma points
    Feb 29, 2012 @ 01:02
    Ian Percival
    0

    well nevermind.... this works:

     

    <xsl:for-each select="$currentPage/descendant::* [@isDoc and string(umbracoNaviHide) != '1' and string(topNav) == '1']">


    The problem was I was saving objects with that value turned off and they will still displaying but then after saving it said "remember to publish to see changes" and a light went off, I hit save and publish and now it is gone from my nav... as I was wanting.

  • Paul Blair 466 posts 731 karma points
    Feb 29, 2012 @ 01:18
    Paul Blair
    0

    looks like you're mostly there. The one thing that might need changing is make the comparision operator "=" instead of "=="

    == is not valid XSLT syntax

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies