0
votes

I'm trying to customize the layout of the Orchard.Comments module's add a comment form in my Orchard theme.

Normally I would use shape tracing to create a new template, it would get populated with the default view cshtml and everything works. This is not working for the EditorTemplate from Comments, and could be an issue with any EditorTemplate override.

This is what I did in this case:

  • Used shape tracing to find Content/Parts_CommentForm.
  • Expand Content_Edit and click on EditorTemplate
  • Click Create for ~/Themes/MyTheme/Views/EditorTemplate-Comment.cshtml

The result is the file created is blank instead of having default view. Because the template file gets used but is now blank, no add comment form displayed.

If I try to use the editor template from the Orchard.Comments module Orchard.Comments/Views/EditorTemplates/Parts.Comments.cshtml I get an error "The model item passed into the dictionary is of type 'Orchard.DisplayManagement.Shapes.Shape', but this dictionary requires a model item of type 'Orchard.Comments.Models.CommentPart'."

The source of the error is when Display is called through /Core/Contents/Views/Content.Edit.cshtml

> Line 3:          @if (Model.Content != null) {
> Line 4:              
> Line 5:                  @Display(Model.Content)
> Line 6:              
> Line 7:          }

Is it possible to override an editor template in the theme and have the model type match the one in the module?

If not, what would be the best way to still generate the edit form based on the given Orchard Shape?

Thanks!

2

2 Answers

0
votes

You should be able to overwrite Editor Templates by creating a folder in your views folder in your theme. I have never tried to override the editor template for comments, don't really know how it all works but I assume it would look like this:

~/Themes/MyTheme/Views/EditorTemplate/Parts.Comment.cshtml

Or something along those lines ^_^

0
votes

It looks like it isn't possible to create alternates for shapes that defined in code (but not in a template). The Orchard major recommends using CSS to make the form look the way you want: http://orchard.codeplex.com/discussions/389726.