In my last article I described Editor’s Favourite contents functionality. The solution consisted of Add to Favourited button and Favourite Content grid widget. Both of those features were available in edit mode. When editor log in to CMS, he lands on Dashboard page. It could be an interesting feature if they could see the list of all their favourites there. I decided to further extend the functionality and prepared dashboard widget with readonly list of editor’s favourite contents.

Defining dashboard widget

Defining dashboard component is similar to regular edit mode components. We need to set client widget type and it’s class has to be annotated with Component attribute. The difference is in category property value. There are three default categories available for components:

  • content
  • cms
  • dashboard

To allow editor to add component to his dashboard we have to use dashboard category.
Dashboard widget - Adding new gadget

The Category property is a generic IEnumerable collection of strings (IEnumerable<string>), so first I simply tried to add dashboard category to FavouriteContent component.

I run the site, but the code did not worked. It turned out that CMS module was not loaded and epi.cms.content.light store was not available. It means that I cannot reuse grid widget and had to prepare new custom component class and new custom client widget.

The component is very similar to edit mode Favourites version. I just change the category to dashboard and set client widget class to favourites.favouriteContentDashboardComponent.

Dashboard widget

The dashboard widget is a readonly list of links. Each link displays the name and status of the content. In the constructor I get favouriteContentStore and then in buildRendering method I fetch links from server.

Below I showed the Favourites component added to dashboard.

Dashboard gadget - favourite content list

New store method

I added new GetEditModeLinks method to FavouriteContentStore store class. It returns list of names, content status and edit mode URLs for favourite content. To generate URL I used public PageEditing.GetEditUrl method, but for page status (formatted name) I had to get code from EPiServer libraries, because it was marked as internal.

One more thing to mention is that module.config for dashboard widget has dependency on Shell module but Edit Mode widget has CMS dependency.

Below is the video that shows usage of dashboard widget.
Using Favourite Contents Dashboard widget