Copied to clipboard

Flag this post as spam?

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


  • Duke Maximus 23 posts 20 karma points
    May 21, 2009 @ 03:41
    Duke Maximus
    0

    Addings multiple conditions in for-each loop

    I had a for-each loop that skipped a few nodeTypeAlias :

    [code]
    ..code...
    [/code]

    Although this worked, the node exceptions had to be customised so I've done this:


    [code]




    ...code...
    [/code]

    But the results isn't filtering the @nodeTypeAlias exceptions I've included in $buildQuery.
    I'm probably missing something in here.

  • Duke Maximus 23 posts 20 karma points
    May 21, 2009 @ 05:43
    Duke Maximus
    0

    I've changed the buildQuery variable to this


    [code]
    [/code]

    and the for-each loop looks like this now:

    [code]

    [/code]

    I'm getting all the nodes though and it isn't filtering the exceptions I've given it. If I manually the exceptions like this:

    [code][/code]

    The results returned filtered. It would be great if someone knew what was going wrong here.



  • Paul Blair 466 posts 731 karma points
    May 21, 2009 @ 05:45
    Paul Blair
    0

    I'm not sure what you are trying to do is possible. What you have created with $buildQuery is a string not a piece of executable XSLT. In languages like TSQL you would say:
    exec $buildQuery
    to execute a string as TSQL.
    I'm not sure if there is a similar function for XSLT

    However, as an alternative would it be possible to add a true/false property to all your document types and then only include the nodes you want. To be sure the property is set correctly you could interrupt the publish event and set the value to true for certain node types...?

  • Duke Maximus 23 posts 20 karma points
    May 21, 2009 @ 05:54
    Duke Maximus
    0

    Hi Spider,

    I realized I can pass an XPath Query to GetXmlNodeByXPath that creates the XPathNavigator for me and I should be able to iterator through that but its weird that the $buildQuery with the foreach loop in it doesn't get the proper filter.

    This filter is for an existing large website and it's something I will be using on other Umbraco sites as well so I'd like to stay away from creating custom properties to deal with this and I've added the exception nodes in the config file.

  • Duke Maximus 23 posts 20 karma points
    May 21, 2009 @ 06:56
    Duke Maximus
    0

    I knew I missed something! Turns out that in my

    [code]

    [/code]

    the value-of has a space in it so instead of looking for @nodeTypeAlias = 'Homepage' it's looking for @nodeTypeAlias = ' Homepage'.



Please Sign in or register to post replies

Write your reply to:

Draft