AI OnAI Off
Cant you just check the PageType property instead of PageName?
private void MyPageList_Filter(object sender, FilterEventArgs e)
{
var pages = e.Pages;
for (int i = pages.Count - 1; i > -1; i--)
{
if (pages[i].PageTypeName == "YourPageTypeNameHere")
{
pages.RemoveAt(i);
}
}
}
It did work but ... Just out of couriosity:
for (int i = pages.Count - 1; i > -1; i--)
May I just ask, why it is '-1'?
Why not
for (int i = pages.Count; i > 0; i--)
a list with 1 items have Count = 1 but pages[0] is that page. pages[1] will throw an error
Hello!
Iam having a PageTree and everything is working fine. But I want to filter out pages of a certain page type. How do I do that best?
Iam trying to follow Fredrik Vigs guide:
http://www.frederikvig.com/2009/07/episerver-web-controls-pagelist/
Looking at the header "Filtering the data", Iam trying to achive that but, as I said, with Page Types. Any ideas?