Try our conversational search powered by Generative AI!

Henrik Fransas
Mar 18, 2014
  3187
(2 votes)

Gadget for Last Updated Pages to work in Dashboard

One change EPiServer did in version 7 was to move the built in gadget for last updated pages from the dashboard to the edit mode in the tree view. Even if it feels like a place more closely related to the function it also made it harder to use, since there is not much room there.

Thankfully with EPiServer 7 and MVC it is incredible easy to create a gadget and since the code for the report on last updated pages are there it is not necessary to invent the wheel again Blinkar. To get back this little nice gadget do like this:

 




1: Create Gadget control
This is based on that you are using MVC on your site.

using System;
using System.Web.Mvc;
using EPiServer.Core;
using EPiServer.ServiceLocation;
using EPiServer.Shell.Gadgets;
using EPiServer.UI.Report.Reports;

namespace SiteName.Controllers.Gadgets
{
    [Gadget(Name = "Updated Pages", Description = "List the last 15 updated pages for this site", Title = "Last updated pages")]
    public class UpdatedPagesController : Controller
    {
        public ActionResult Index()
        {
            var instance = ServiceLocator.Current.GetInstance<ChangedPagesData>();
            int numOfRows = 0;

            //It is important to set the parameters correct since for example if you define other sorting than "Saved" nothing will be returned, why? I do not know
            var pages = instance.GetPages(ContentReference.StartPage, -1, false, DateTime.UtcNow.AddDays(-14),
                DateTime.UtcNow, "Saved", 15, 0, out numOfRows);
   
            return View(pages);
        }


    }
}

2: Create the View

@model EPiServer.Core.PageDataCollection

@{
    ViewBag.Title = "Updated pages";
    Layout = null;
}

@if (Model.Any())
{
    <div>
        <table class="epi-default epi-default-legacy" cellspacing="0" border="0" id="ctl00_FullRegion_MainRegion_ReportView" style="border-style:None;width:100%;border-collapse:collapse;">
            <tr>
                <th scope="col">Pagename</th>
                <th scope="col">Last changed</th>
                <th scope="col">Changed by</th>
                <th scope="col">PageType</th>
            </tr>
            @foreach (var entry in Model)
            {
                <tr>
                    <td style="width: 27%;">
                        <a href="/EPiServer/CMS/#context=epi.cms.contentdata:///@entry.PageLink.ID.ToString()" target="EPiServerMainUI" title="PageType: @entry.PageTypeName PageId: @entry.PageLink.ID.ToString()">@entry.PageName</a>
                    </td>
                    <td>
                        <span title="@entry.Saved.ToString("yyyy-MM-dd HH:mm:ss")"> @entry.Saved.ToString("yyyy-MM-dd")</span>
                    </td>
                    <td>
                        @entry.ChangedBy
                    </td>
                    <td>
                        @entry.PageTypeName
                    </td>
                </tr>
            }
        </table>
    </div>
}

The layout and styling isn’t the best and I have used the same code that EPiServer use so I am depending on their styles.

I will update (or write a new) post on this with a updated version that are using AngularJS and better styling to do filtering/sorting and so on, but this is how easy it is to create your own Gadget to use in the Dashboard.

Happy coding!

Mar 18, 2014

Comments

nitin anand
nitin anand Jun 29, 2018 08:34 AM

Hi, nice article. is there any way to get the recently changed blocks as well? can you guide how can i see the episerver code from recently changed pages.aspx.cs file

Henrik Fransas
Henrik Fransas Jun 29, 2018 08:48 AM

Hello

It should be possible but I do not think that it is a build in function so you need to either query the database yourself of run the query through Episerver Find or something

Please login to comment.
Latest blogs
Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog