Including a Part in custom coded view.

Topics: Troubleshooting, Writing themes
Sep 28, 2014 at 4:23 PM
I'm trying to include comments and the comments form Parts in a custom coded view in orchard 1.8.1. For an object type that I created in the dashboard that includes the comments part.
So as to let Orchard create that part of the view rather than hand code a new way of displaying all the comments for that item.

I've tried a number of ways but so far have not managed to do so.
The closest possible solution I've come across is http://weblogs.asp.net/bleroy/so-you-don-t-want-to-use-placement-info, but after adding the Utils class to my theme modules it is unable to find ClaySharper.

Some further digging is leading me to believe that this used to be a valid solution some two years back, but now ClaySharper has been removed from Orchard?

Does anyone know anything about this, or if there is a different better solution to do this now?

Regards, Styrmir.
Sep 28, 2014 at 5:08 PM
Just to be clear.
An "object type" means you created a ContentType with the comments part attachted and override the shape? Or you have your own Controller and create your own shape?
Sep 29, 2014 at 12:07 PM
That is correct Benchi.
I created a new Content Type and attached a comments part to it, all via the dashboard in Orchard. I did not create a new module using the code generator with its own controller etc.

I've since created an alternate view using the shape tracer and am trying to make Orchard generate the comments part section onto that page. I have everything looking and laid out like I want it after manually placing the various pieces from the Content Type onto the corresponding view file, but I'd like to have orchard render the comments part and comments form part for me., like it would do if I had not created an alternate view.
Sep 29, 2014 at 7:47 PM
I am not sure what is the best and generic way. But one time I had the same problem and I started to debug in my view and found the correct shape in my model. When you found the correct Shape in my model all you have to do is
Display(Model.Content.Items[0])
In this case Model.Content.Items[0] are the correct shape for me.

But as I said in the beginning, I don't know if there is a more elegant and more generic way to solve your problem.
Marked as answer by StyrmirCPX on 10/1/2014 at 9:14 AM
Oct 1, 2014 at 5:22 PM
Thank you benschi11, I found the shapes under Model.Content unlike Model.ContentItem that I use for finding individual pieces of data from a ContentType.

In my case it was as simple as adding:

Display(Model.Content.Items[6]) <!-- comments -->
Display(Model.Content.Items[7]) <!-- comment form -->

to my view file. As you said the individual numbers will wary depending between ConentTypes.

Perhaps somewhat ambiguous to go by some arbitrary iterated numbers in the code without looking up what each number represents, but it's a clean solution at least and commenting will make the code clear to read.
Oct 3, 2014 at 9:15 AM
You can try this:

Gat all tags by calling: Model.ContentItem.TagsPart.CurrentTags

and then use foreach to display them.
Oct 3, 2014 at 9:38 AM
Wrong discussion. Sorry.

For comments, you may try this:

@Display(Model.ArticleComments)
@Display(Model.ArticleCommentsForm)