h
Is there anyway of extracting a list of all page nodes that have been edited since a particular date?
a
This should give you all content edited within the last seven days:
Copy code
csharp
@using Umbraco.Cms.Core.Services
@inject IContentService ContentService

@{

    DateTime date = DateTime.Now.AddDays(-7);

    var content = ContentService
        .GetPagedDescendants(-1, 0, int.MaxValue, out long _)
        .Where(x => x.UpdateDate >= date);

}
Might be take a bit of time on large sites, so keep in mind where you use this. The
GetPagedDescendants
method also takes an extra
filter
option. I haven't used this before, but maybe it possible to do the filter by date there instead of using the
.Where()
method.
Didn't see the v8 tag, but the code should be somewhat similar in Umbraco 8
I don't have an Umbraco 8 site at hand for testing, so this is supposedly how you'd use the filter/query option i umbraco 10:
Copy code
csharp
@using Umbraco.Cms.Core.Services
@using Umbraco.Cms.Core.Models
@using Umbraco.Cms.Core.Persistence.Querying
@using Umbraco.Cms.Core.Scoping

@inject IContentService ContentService
@inject ICoreScopeProvider ScopeProvider

@{

    DateTime date = DateTime.Now.AddHours(-1);

    IQuery<IContent> query = ScopeProvider
        .CreateQuery<IContent>()
        .Where(x => x.UpdateDate >= date);

    var content = ContentService
        .GetPagedDescendants(-1, 0, int.MaxValue, out long total, filter: query);


    <pre>@total</pre>

    foreach (var item in content)
    {

        <pre>@item.Id -> @item.Name</pre>

    }

}
h
Thanks, I will give it a whirl, it is a dev site so not too bothered about performance 😃