Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'd like to do something like
if (model.id(1066).descendantsorself() == true) { do stuff }
That, I presume, merely generates a list.I only want to execute the block if the node matches that criteria.
How to run such a check?
Thanks,
Kyle
This almost looks right, but its not working:
if (Model.IsDescendantOrSelf(1066)) { do something }
Hi Kyle,
Just a thought it might be more efficient to do the reverse, ie, check to see if the current page is an ancestor of 1066 ?
Dang, Hendy, I was hoping that was it: (Model.IsAncestorOrSelf(1066)) or @(Model.IsAncestorOrSelf(1066)) render the same 'nothingness
Once again, my umbraco partner in crime crafted an answer:
@using umbraco.MacroEngines; var targetId = 1202; DynamicNodeList ancestors = Model.AncestorsOrSelf();if (@ancestors.Items.Any(x=>x.Id==targetId)) {do stuff}
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Running a conditional check for current node descendantsorself
I'd like to do something like
if (model.id(1066).descendantsorself() == true) { do stuff }
That, I presume, merely generates a list.I only want to execute the block if the node matches that criteria.
How to run such a check?
Thanks,
Kyle
This almost looks right, but its not working:
if (Model.IsDescendantOrSelf(1066)) { do something }
Hi Kyle,
Just a thought it might be more efficient to do the reverse, ie, check to see if the current page is an ancestor of 1066 ?
Dang, Hendy, I was hoping that was it: (Model.IsAncestorOrSelf(1066)) or @(Model.IsAncestorOrSelf(1066)) render the same 'nothingness
Once again, my umbraco partner in crime crafted an answer:
is working on a reply...