Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Custom Content


Following this article I implemented some similar functionality.

But I don't get the comments to show up under  "For this page". However, if I add I can see the comments under "For this page" -> (A folder named same as page) They are there. But they do not automagically appear as described in the article if I leave roots with an empty enumerable.

What am I missing?

        public override IEnumerable Roots
                return new List { SiteDefinition.Current.ContentAssetsRoot };

Thanks in advance!

Mar 01, 2016 8:46

Roots tells you where you can create comments. What happens if you leave it as empty IEnumerable and then add comment as you would add a local image in page files?

Mar 01, 2016 9:38

Thats the problem. :-)
It displays nothing if I leave it as an empty enumerable. But according to article. It should automatically show "For this page"-folder and list comments therein. I've followed the article but it does not show any content unless I set Roots to ContentAssetsFolder. But setting this is not what I want. I want it to just show the comments for the specific  page I am looking at. 

Mar 01, 2016 10:20

I'm wondering if you are creating the comments at the right place. How do you create them? Programmatically or by clicking in edit? Are you creating them in the local page files folder or in root for assets?

Mar 01, 2016 11:59
                    PageData page = _contentRepo.Get<PageData>(new ContentReference(comment.PageId));
                    ContentAssetFolder assetFolder = _contentAssetHelper.GetOrCreateAssetFolder(page.ContentLink);
                    Comment save_comment = _contentRepo.GetDefault<Comment>(assetFolder.ContentLink);
                    save_comment.UserComment = new XhtmlString(comment.Text);
                    save_comment.CommentParentLink = (comment.ParentId.HasValue) ? new ContentReference(comment.ParentId.Value) : ContentReference.EmptyReference;
                    save_comment.CommentUserName = EPiServerProfile.Current.UserName;
                    save_comment.Name = "Comment_" + EPiServerProfile.Current.UserName.Replace(" ", "") + "(" + DateTime.Now.ToShortDateString() + ")";
                    _contentRepo.Save(save_comment, SaveAction.Publish, AccessLevel.NoAccess);

comment.PageId = ID for the page on which the comment is posted. 

It places it in some folder connected to the page atleast. 

If I set Roots to ;


I can browse the comments under Folder

Mar 01, 2016 15:08

That code looks sound. Uploading images to local page folder works as expected? They end up in "for this page folder?". Just so there isn't any configuration error...

Mar 01, 2016 16:32

I have no problem uploading images to "For this Page" -folder. I'm running version 9.6.1

Mar 02, 2016 8:07
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.