Comments on pages

Vote:
 

Which would be the best way to add comment functionallity on CMS page types? I have found so many different answers i don't really know which to use. I can't get a grip on the CommentHandler-class and how to reference a Entity for a page...

#53413
Sep 07, 2011 14:59
Vote:
 

You need an entity corresponding to the page. Previously there was the open source PageEntity, and now Relate 2 R2 seems to have it (or something similar) built-in, see "Social Pages" in this article: http://world.episerver.com/Articles/Items/EPiServer-Relate-2-R2/

#53416
Sep 07, 2011 16:06
Vote:
 

Have you looked at this yet Jonas?

http://world.episerver.com/Blogs/Patrick-Iberts-blog/Dates/2011/8/Implement-a-comment-system-using-EPiServers-datastore-by-using-Paul-Smiths-DynamicDataStoreSession-class/ 

#53417
Sep 07, 2011 16:11
Vote:
 

I looked at the Pageentity-project, the code i found seemed te only support the Wiki and not CMS-Pages. Maybe i didn't look hard enought :). Creating an Entity sounds like the best way... building a comment system in CMS isn't that hard, but i want to use Relate+.

Does anybody know of a good article describing how to implement PageEntity with CMS pages?

#53428
Sep 08, 2011 13:54
Vote:
 

I'm not sure if things are going forward or backwards for me right now, but i'm sure struggling.... I created a PageEntity called CMSPageEntity and tried to add a Tag to it using this code:

CMSPageEntity x = (CMSPageEntity)new CMSPageEntity(CurrentPage.PageGuid).Clone();
UserAuthor user = new UserAuthor(CommunitySystem.CurrentContext.DefaultSecurity.CurrentUser);
Tag tag = new Tag("Testtagg");
ICategory cat = new Category("testcat");
x.EntityTags.Add(new EntityTag(tag, cat, user));
PageEntityHandler.UpdatePageEntity(x);

 

It results in this exception, what do i miss here?

 

The specified object of type 'EPiServer.Templates.RelatePlus.Templates.PageEntity.CMSPageEntity' in argument named 'pageEntity' is not committed to the database and cannot be used as an input parameter.

 

#53453
Sep 09, 2011 8:02
Vote:
 

You have to use PageEntityHandler.AddPageEntity when you're creating a new entity.

#53454
Sep 09, 2011 8:08
Vote:
 

Ok, so finally i got this to work. First i created a custom PageEntity, constructed som logic to handle the creation (or use) of it and som other basic stuff. The creation of comments works fine, but now i struggle getting the comments instead... i need to get all comments for a specific PageEntity, so i have two options: GetComments or GetQueryResult. GetComments should be the way, but it takes an IAuthor as parameter. I don't want to filter by author, is there a way to do this? GetQueryResult is more flexibel, but i cannot find any parameter to filter by "Commented Entity"...

#53512
Sep 13, 2011 8:30
Vote:
 

Passing null for author should get you all comments regardless of author.

#53514
Sep 13, 2011 8:39
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.