Easiest thing to do is to create a container page called Comments under your article page, and then save each comment as EPi page.
CommentPage can have properties: UserId, IsApproved, etc.
Something like this:
[ContentType(GUID = "21884d6e-c1cf-4124-bc03-a06aed328780")] public class CommentPage : PageData { [Display( GroupName = SystemTabNames.Content, Order = 100)] public virtual string UserId { get; set; } [Display( GroupName = SystemTabNames.Content, Order = 200)] [UIHint(UIHint.Textarea)] public virtual string Text { get; set; } [Display( GroupName = SystemTabNames.Content, Order = 300)] public virtual bool IsApproved { get; set; } }
That's all you need.
You don't have to create a page controller, because you probably don't want to have comments as stand-alone pages (http://mydomain.com/some-article/comments/comment-1)
The page w/o page controller (container page) can be editable in EPi, but throws 404 when accessed directly in browser
How the admin will be notified when the new comment is added? Will he have to go through all the nodes and see which ones are newly added.
Something like this?
public class CommentService : ICommentService { public void CreateComment(PageReference articlePage, string userId, string text) { // TODO: check if comments are disabled on the page // TODO: check if Comments container exists // TODO: create a comment page // TODO: notify admins } }
Inside CreateComment method, you can get an external friendly URL of a comment page and email it to adminstrators.
If you don't want to create your own solution, you could try https://disqus.com/
Thanks Dejan, I wil try to implement it.
I sent you an email (on gmail), did you receive it?
Hi,
I am trying to build a comment section for a news module, I have below question regarding this:
Where the comments will be saved? I guess it should be saved in a new table called comments in the Database. How this is done? I also need to associate UserID with the comments.
The WebAdmin will be able to approve/reject the comment. He should see all the comments will approve / reject button. How to achieve this?
Thanks
Pankaj