Render Comments Part when Blog is already overriden

Topics: Customizing Orchard
Editor
Oct 10, 2011 at 4:56 PM

 I am trying to render the Comments Part of a Blog Post after I already have overriden the BlogPost content type. I have a template file for blog posts called:

Content-BlogPost.Detail.cshtml

Inside this file I am rendering a blog post in a custom way. I am able to grab the comments part like this:

var comments = ((IContent)Model.ContentItem).As<CommentsPart>();

But now to render the comments by hand I need to know how to call the Render Engine here. I am trying this:

@Display(comments);

But it is not working. Any help would be great.

I saw a blog post with something like this for tags though:

@Display(New.MyCommentShape(Comments: comments.Comments))

Coordinator
Oct 10, 2011 at 5:01 PM

Display works on shapes, not content items, so you need to grab the shape that already exists for the comments. See http://weblogs.asp.net/bleroy/archive/2011/07/31/so-you-don-t-want-to-use-placement-info.aspx

Editor
Oct 10, 2011 at 5:40 PM

Thanks! This worked. I had to make a couple of edits:

In my template I had to cast Model to Shape before passing it. Then in Util I modified the argument to be be Shape instead if IShape.

@Display(ShapeHelper.Find((Shape)Model, "Parts_Comments"))

public static dynamic Find(Shape model, string name)