在 EpiServer 中查找新的和更新的页面

发布于 2024-09-30 13:50:24 字数 1207 浏览 6 评论 0原文

我需要在我们的 Episerver Intranet 中显示新创建和更新的页面列表 - 例如每个页面的最后十个。我尝试使用 FindPagesWithCriteria ,但这没有返回任何结果。这是我尝试过的代码:

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);

我还尝试使用 RecentlyChangedPagesFinder (详细信息here) - 这会返回一些结果,但是当我尝试使用这组结果来构建要进行数据绑定的 PageCollection 时进入 PageList,我再次没有得到任何输出。我看不到我可以将其用于新页面,只能用于更新的页面。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的往事 2024-10-07 13:50:24

属性名称应为“PageCreated”。

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

您还可以通过如下方式改进 FindPagesWithCriteria 语法:

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);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文