Can anyone help me please.
I have 6 pages of the "type" disply article (displayes headline, abstract and ful lstory text).
One of these pages has the attribute VisibleInMenu set to false (do not show in menu).
I want to retrieve the page that has the attribute VisibleInMenu set to FALSE by using PropertyCriteria.
But I get 0 results by doing this. Why?
Here is my code:
PropertyCriteriaCollection criterias = new PropertyCriteriaCollection();
PropertyCriteria criteria = new PropertyCriteria();
criteria.Condition = CompareCondition.Equal;
criteria.Type = PropertyDataType.Category;
criteria.Value = "false";
criteria.Name = "VisibleInMenu";
criteria.Required = true;
criterias.Add(criteria);
PageDataCollection ChildPages = EPiServer.Global.EPDataFactory.FindPagesWithCriteria(CurrentPage.PageLink, criterias);
SideInfo.PageLink = ChildPages[0].PageLink;
I've also tested setting Value to "true".
Steven,
Not all of the 'built-in' properties have names that match what you see in the Editor.
Look at PageData.Property in the SDK.
In your code sample you need to change criteria.Name to be "PageVisibleInMenu", and criteria.Type to PropertyDataType.Boolean - it should work then, I think.
/Mark
I'm not sure if it will work, but because it is one of the built in properties, and is not saved in the tblProperty table, it might. You will have to try.
But - for custom properties, searching for a "false" value for a PropertyType.Boolean will not work. The reason is that "false" values are not saved into the database - to preserve space I guess. So, the fact that it does not exist imply that it is false, but you cannot search for values that do not exist :-)
This is why you cannot "undo" a Dynamic Property setting if is a bool. You can always set it to true on one page, but you cannot set any children of that one to false, and make it stick.
And yes, I agree, this is not one of the more intuitive features in EPiServer :-)
/Steve
var criteria = new PropertyCriteria(){
Condition = CompareCondition.Equal,
Value = "false",
Type = PropertyDataType.Boolean,
Required = true,
Name = "PageVisibleInMenu"
};
PropertyCriteriaCollection criterias = new PropertyCriteriaCollection(); PropertyCriteria criteria = new PropertyCriteria(); criteria.Condition = CompareCondition.Equal; criteria.Type = PropertyDataType.Category; criteria.Value = "false"; criteria.Name = "VisibleInMenu"; criteria.Required = true; criterias.Add(criteria); PageDataCollection ChildPages = EPiServer.Global.EPDataFactory.FindPagesWithCriteria(CurrentPage.PageLink, criterias); SideInfo.PageLink = ChildPages[0].PageLink;
I've also tested setting Value to "true".