A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More


Nov 1, 2010
  6519
(0 votes)

A social plugin for EPiServer

The background

Since the release of EPiServer 6 i haven´t been engaged in any pure EPiServer projects and therefor haven´t got to use the new and shiny features that comes with version 6. Because of that (and the fact that my EPiServer developer certificate soon will expire again) I started playing around with the Dynamic Data Store recently to get a better grip on it.

The goal

The goal of this, other than me getting to know DDS, was to create a plugin for EPiServer that provided some basic “social” features like comments and ratings. There has been numerous blogposts and demos on how to implement this kind of functionality using DDS, but I thought I would take it a step further and create a ready-to-use plugin.

Besides that, I wanted the use of it to be as simple as possible. No configuration, no setup, no extra files. Just drop an assembly in the bin-folder and get busy coding.

The result

The result of all this became a plugin that provides a simple API for creating comments and ratings for EPiServer pages. It also contains a simple editmode plugin for managing these for each page.

This is to be considered in an alpha stage. There still remains some work before it is ready and additional features will be added along the way. Feel free to try it out.

This post focuses on how to use the EPiSocial plugin rather than how DDS works.

Single assembly deployment

Well, almost. The plugin itself is just a single assembly, but it depends on both AutoMapper and StructureMap.

So the deployment consists of adding the following three assemblies to your bin-folder:

  • EPiSocial.dll
  • AutoMapper.dll
  • StructureMap.dll

Then add a reference to EPiSocial and you´re done.

POCO objects

The comments and ratings are simple POCO objects and looks like this:

PageComment class:

   1: public class PageComment
   2: {
   3:         public string Id { get; set; }
   4:         public string Text { get; set; }
   5:         public int PageId { get; set; }
   6:         public string PageLanguage { get; set; }
   7:         public Author Author { get; set; }
   8:         public DateTime Created { get; set; }
   9: }

PageRating class:

   1: public class PageRating
   2: {
   3:         public string Id { get; set; }
   4:         public int Rating { get; set; }
   5:         public int PageId { get; set; }
   6:         public string PageLanguage { get; set; }
   7:         public Author Author { get; set; }
   8:         public DateTime Created { get; set; }
   9: }

Author class:

   1: public class Author
   2: {
   3:         public string Email { get; set; }
   4:         public string Name { get; set; }
   5: }

Usage - The easy way

The EPiSocial plugin provides a EPiSocialService class that is the entrypoint for using the API. It has a singleton instance, EPiSocialService.Instance, to use.

The EPiSocialService itself has two properties, a CommentRepository and a RatingRepository, that provides methods for adding, retrieving and removing comments/ratings.

Add a comment:

   1: var pageComment = new PageComment
   2:                   {
   3:                         Text = "Some text",
   4:                         PageId = 3,
   5:                         PageLanguage = "sv",
   6:                         Created = DateTime.Now,
   7:                         Author = new Author { Name = "Some name" }
   8:                   };
   9:  
  10: EPiSocialService.Instance.CommentRepository.AddComment(pageComment);

Get comments for a page:

   1: var commentsForPage = EPiSocialService.Instance.CommentRepository.GetCommentsForPage(3);

Languagespecific overload:

   1: var commentsForPage = EPiSocialService.Instance.CommentRepository.GetCommentsForPage(3, "sv");

Usage - The recommended way

Even though the above example is really quick and easy to use, you really should not depend directly on the EPiSocialService class. As the good developer you are you should instead have dependencies on the interface IEPiSocialService or any of the repository interfaces ICommentRepository or IRatingRepository.

Editmode plugin

When adding the EPiSocial assembly you also get an editmode plugin added to EPiServer. It is a tab in the editpanel of each page named “EPiSocial”. The plugin contains some statistics for the current page and the ability to reset ratings and remove unwanted comments.

EPiSocial

This has been an introduction to EPiSocial. The project is just in it´s first stumbling steps and any feedback is appreciated.

The plugin can be downloaded here for now. Feel free to try it out.

Nov 01, 2010

Comments

Please login to comment.
Latest blogs
A day in the life of an Optimizely OMVP: Learning Optimizely Just Got Easier: Introducing the Optimizely Learning Centre

On the back of my last post about the Opti Graph Learning Centre, I am now happy to announce a revamped interactive learning platform that makes...

Graham Carr | Jan 31, 2026

Scheduled job for deleting content types and all related content

In my previous blog post which was about getting an overview of your sites content https://world.optimizely.com/blogs/Per-Nergard/Dates/2026/1/sche...

Per Nergård (MVP) | Jan 30, 2026

Working With Applications in Optimizely CMS 13

💡 Note:  The following content has been written based on Optimizely CMS 13 Preview 2 and may not accurately reflect the final release version. As...

Mark Stott | Jan 30, 2026

Experimentation at Speed Using Optimizely Opal and Web Experimentation

If you are working in experimentation, you will know that speed matters. The quicker you can go from idea to implementation, the faster you can...

Minesh Shah (Netcel) | Jan 30, 2026