SaaS CMS has officially launched! Learn more now.

Filter pages based on Start publish date

Hi I want to get list of pages published between today and last 7 days. Whats the best & quickest way of doing that? Cheers Vish
Feb 01, 2007 14:06
Hey there, You will want to use the FindPagesWithCriteria method of the DataFactory. Be careful though as this will work directly against the database. Take a look at the following code: PropertyCriteriaCollection col = new PropertyCriteriaCollection(); // create a criteria to include pages published in the last 7 days PropertyCriteria critCreated = new PropertyCriteria(); critCreated.Condition = EPiServer.Filters.CompareCondition.GreaterThan; critCreated.Type = PropertyDataType.Date; critCreated.Name = "PageStartPublish"; critCreated.Value = DateTime.Now.AddDays(-7).ToString(); critCreated.Required = true; col.Add(critCreated); // pass the criteria into the find method to locate all pages matching the criteria. PageDataCollection pages = Global.EPDataFactory.FindPagesWithCriteria(Global.EPConfig.RootPage, col); newContentNewsList.DataSource = pages; newContentNewsList.DataBind(); Cheers, Jeremy.
Feb 02, 2007 3:45

Hmm, I have been stuck with this for a while until I saw this example and noticed that you are using PageStartPublish and I am using StartPublish when adding criteria. BUT the strange thing is that I am using StartPublish when rendering out the result?!

I can not find any property called PageStartPublish and still it works?!
Can someone explain where PageStartPublish comes from?

Mar 30, 2009 14:44


All built in metadata properties ( like start publish, name, and category) are prefixed by "Page", ie PageName, PageCategory and PageStartPublish. So when you want to search for them or get them directly from the PageData objects Property collection, you need to use that name ( CurrentPage.Property["PageStartPublish"] ).

However, the PageData class has a few convenience accessors to the most common ones. That's why you can access the value directly through CurrentPage.StartPublish. However the actual backing store will store the property as PageStartPublish.


Per Gunsarfs
EPiServer CMS Develompent Team

Mar 30, 2009 15:08
You can find these propertynames in the SDK:
Mar 30, 2009 22:11
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.