views:

12

answers:

1

I have a requirement to display lists of newly-created and updated pages in our Episerver intranet - say the last ten of each. I've tried using FindPagesWithCriteria but this returns no results. Here's the code I've tried:

PageDataCollection recentPages;
PropertyCriteriaCollection criteria;
PropertyCriteria upperBound;
PropertyCriteria lowerBound;

criteria = new PropertyCriteriaCollection();

upperBound = new PropertyCriteria();
upperBound.Condition = CompareCondition.LessThan;
upperBound.Type = PropertyDataType.Date;
upperBound.Value = DateTime.Today.ToString();
upperBound.Name = "Created"; // Or Saved for updated pages

criteria.Add(upperBound);

lowerBound = new PropertyCriteria();
lowerBound.Condition = CompareCondition.GreaterThan;
lowerBound.Type = PropertyDataType.Date;
lowerBound.Value = DateTime.Today.AddDays(-7).ToString();
lowerBound.Name = "Created";

criteria.Add(lowerBound);

recentPages = DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, criteria);

I've also tried using the RecentlyChangedPagesFinder (as detailed here) - this returns some results, but when I try to use the set of results to build a PageCollection to databind into a PageList, again I get nothing output. And I can't see that I could use that for new pages, only updated ones.

+1  A: 

The property name should be "PageCreated".

http://epiwiki.se/developing/properties/all-built-in-properties

You can also improve your FindPagesWithCriteria-syntax by going something like this:

var criterias = new PropertyCriteriaCollection
{
    new PropertyCriteria()
    {
        Name = "SomeProp",
        Type = PropertyDataType.PageType,
        Value = "eh",
        Condition = CompareCondition.Equal,
        Required = true
    },
    new PropertyCriteria()
    {
        ...
};

var pages = DataFactory.Instance.FindPagesWithCriteria(somePageLink, criterias);
Johan Kronberg