Copied to clipboard

Flag this post as spam?

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


  • Steven 33 posts 166 karma points
    Jul 24, 2013 @ 18:00
    Steven
    0

    Recursive usage of data type 'True/False'

    Hi Folks,

    I seem to be a bit 'lost' when using recursive fields of data type 'True/False' ... it simply does not seem to work ...

    When I define a value on a node itself then the following code bits work:

    if ( @Model._useCookieConsent == true )

    if ( @Model.GetProperty("useCookieConsent",true).Value == true ) 

    When I don't set a value then the recursive doesn't work ... it simply will not drill down to the parent node ... but always returns 'false' or '0' instead ... I have the 'feeling' that somehow the system does not 'see' the difference between 'not set' and the value 'false' ... hence it will never go further down ...

    Everything works fine for 'string' data types ...

    Thanks,

    Steven

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jul 26, 2013 @ 19:49
    Jeavon Leopold
    101

    Hi Steven,

    There are a few options here, as you have noted if the property exists then it is either true or false so the recursive option is not really going to work. So here are the options:

        //using uQuery
        if (uQuery.GetCurrentNode().GetAncestorOrSelfNodes().Any(x => x.GetProperty<bool>("useCookieConsent")))
        {
        }
    
        //using a typed DynamicNode
        if (new DynamicNode(Model.Id).AncestorsOrSelf().Any(x => x.GetPropertyValue("useCookieConsent") == "1"))
        {               
        }
    
        //using DynamicNode
        if (Model.AncestorsOrSelf().Where("useCookieConsent").Any())
        {                
        } 

     Thanks,

    Jeavon

  • Steven 33 posts 166 karma points
    Jul 31, 2013 @ 13:16
    Steven
    0

    Hey Jeavon,

    Thanks man !

    Solved it with the second option ...

    Steven

Please Sign in or register to post replies

Write your reply to:

Draft