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 ...
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())
{
}
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
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:
Thanks,
Jeavon
Hey Jeavon,
Thanks man !
Solved it with the second option ...
Steven
is working on a reply...