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
#12918 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.
    #15086 Feb 02, 2007 3:45
  • Member since: 2009
     

    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?

    #28949 Mar 30, 2009 14:44
  • Member since: 2005
     

    Hi

    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.

    Regards

    Per Gunsarfs
    EPiServer CMS Develompent Team

    #28951 Mar 30, 2009 15:08
  • Member since: 2004
     
    You can find these propertynames in the SDK: http://sdk.episerver.com/library/cms5/html/P_EPiServer_Core_PageData_Property.htm
    #28958 Mar 30, 2009 22:11