Copied to clipboard

Flag this post as spam?

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


  • sun 403 posts 395 karma points
    Nov 21, 2012 @ 09:32
    sun
    0

    How to test if one value is existed in a couple of values?

    I use 

    <xsl:variable name="nodes" select="$currentPage/ancestor-or-self::*[@isDoc and @level='1']//*[@isDoc and umbraco.library:Split(tags,',')//value=$currentPage/descendant-or-self::*[@isDoc and isTag='1']/@id]"/>

    this xsl will select some nodes which tags field value is include some nodes id of currentpage//*

    But it's very slow.

    I want to try Razor, Who can give me one Razor example.

  • Richard Terris 273 posts 715 karma points
    Nov 21, 2012 @ 10:03
    Richard Terris
    0

    I think you could either use plain C# :

    foreach(var node in Model)

    {

    if(node.Level == "1" && node.getProperty("isTag") == "1")

    {

    //do stuff

    }

    }

    or use lambda:

    foreach(var node in Model.Where(x=>x.Level == "1").Where(x=>x.getProperty("isTag") == "1")

    {

    // do stuff

    }

  • Richard Terris 273 posts 715 karma points
    Nov 21, 2012 @ 10:10
    Richard Terris
    0

    Actually I think a better solution would be:

    foreach(var node in Model.Where(x=>x.Level == "1" :

    x.getProperty("isTag" == "1")

    {

    // do stuff

  • sun 403 posts 395 karma points
    Nov 21, 2012 @ 10:11
    sun
    0

    The main problem is how to do following wit razor:

    umbraco.library:Split(tags,',')//value=$currentPage//*[@isDoc]/@id

  • Richard Terris 273 posts 715 karma points
    Nov 21, 2012 @ 10:34
    Richard Terris
    0

    If tags is a property you should be able to use .Split[','] in Razor?

Please Sign in or register to post replies

Write your reply to:

Draft