|Number of votes:||2|
Do you want Community features on your CMS pages? PageEntity to the rescue
For a while now you have been able to rate articles and blog posts, as well as see most viewed, most popular and a Tag Cloud for each. These items are standard CMS pages but with a custom made EPiServer Community Module hooked up, aka PageEntity.
However, this blog post will not go into detail on how to create a community module cause it is better explained in detail in Joel Abrahamsson’s article series on the subject. Read it first and you will better understand this PageEntity module.
We started of simple and created the PageEntity class for all our objects, and then we could pass in what type of page it is (article, blog, standard, etc) to the constructor. Well we created PageEntityTypes enum to handle it (the observant one can see that not all of them are implemented live yet)
Then for example to Tag an existing Article page looks like this:
The code above assumes you have a PageEntity property named CurrentPageEntity.
However this approach soon appeared to be not good enough. It worked for most situations except when you wanted a Tag Cloud of Article type.
Version 0.2 was to make PageEntity class abstract and create about 9 subclasses of it to get a specific type. Below example for a EPiServer famous standard page
The CurrentPageEntity moved to a base class to handle all pages entity types, it got a little large for a property…
We wanted the website editors to enable/disable PageEntity function on parts of the site, hence the EnableVisit, EnableTagging and ShowRating dynamic properties above. On the World we also use several community sites, therefore check of SiteHandler.Currentsite. We also determined to reference all pages by PageGuid to be on the safe side.
The method PageEntityUtils.GetPageEntityType is very simple, it helps determine what type of page it is. Example for wiki page:
You have to handle deleted pages with a PageEntity reference. Our choice was to create a httpmodule (PageEntityEventHandler.cs) and remove it.
file you see how we added it to the WikiX article page.
- Add the cs. files to your project,
- Run the supplied sql script to create tblPageEntity and the stored procedures
- Then modify your code to create PageEntity of your choice. (Update *enum, *subclasses, *utils)
Feedback and suggestions for improvement is welcome. Remember this module is not supported by EPiServer. It just demonstrates how to apply EPiServer Community features on CMS pages.
In a not so distant future release of the community you will also be able to comment your page entities. Sweet?!
Please login to comment.