I am trying to create a variable that will store the document types which contain a property of visibleTopMenu which is a data type of true / false.
I am trying to collect the documentTypes which contain this property and where the value is true. These documentTypes are nested a couple of rows deep from the home page, but I thought this wouldn't make a difference.
My code is as follows:
@{
var home = CurrentPage.Site();
var selection = home.Children.Where("visibleTopMenu");
}
selection is returning no values, although there are about 5 documentTypes which have this property set to true. Does anyone know why?
@{
var home = CurrentPage.Site();
var selection = home.Descendants().Where("visibleTopMenu");
}
home.Children() will only give you the nodes that are directly under your home node, where as home.Descendants() will give you all the nodes under home no matter how many rows (levels) they are nested down.
Also, I think you are talking about documents (as in the content tree structure) and not document types, since document types are definitions. Documents are the one which contain the data.
Awesome, great job Jon-Paul! Remember however to check that the child has that property, since all the descendants of Home might not have the visibleTopMenu property. You can check this like:
if (child.HasProperty("visibleTopMenu") && child.HasValue("visibleTopMenu") && child.GetPropertyValue("visibleTopMenu") == true)
searching for certain document types
Hi,
I am trying to create a variable that will store the document types which contain a property of visibleTopMenu which is a data type of true / false.
I am trying to collect the documentTypes which contain this property and where the value is true. These documentTypes are nested a couple of rows deep from the home page, but I thought this wouldn't make a difference.
My code is as follows:
selection is returning no values, although there are about 5 documentTypes which have this property set to true. Does anyone know why?
Thanks for any help provided.
Hi Jon-Paul!!!
Try Descendants inseat of Children.
home.Children() will only give you the nodes that are directly under your home node, where as home.Descendants() will give you all the nodes under home no matter how many rows (levels) they are nested down.
I agree with Dennis.
Also, I think you are talking about documents (as in the content tree structure) and not document types, since document types are definitions. Documents are the one which contain the data.
Hi
Thanks for the replies. I actually solved it like this:
Thanks for your help!
Awesome, great job Jon-Paul! Remember however to check that the child has that property, since all the descendants of Home might not have the visibleTopMenu property. You can check this like:
is working on a reply...