This project is read-only.

Custom BodyPart + Summary View...

Topics: Customizing Orchard, Troubleshooting, Writing modules
Jul 14, 2011 at 3:20 PM

Hello community!

I''ve managed to create a custom BodyPart named "UberBody" and I've replaced body part from Blog with that one. As described here

Everything seems cool, but I'm having a problem with comprehending naming policy for Views. What I would like to change is appearance of Summary displayType for my blogPost that has UberBody content part.

So I've made a custom view... UberBody.Summary.cshtml nested it in Parts subdir but that is obviously not the correct way to do it.

Full path is... .\src\Orchard.Web\Modules\UberBody\Views\Parts\UberBody.Summary.cshtml

What am I doing wrong?

Thank you!



Jul 15, 2011 at 11:24 PM

This should work. Here's how this works: your driver creates a shape (with a name) and then this name gets resolved to a template file name. What I'm suspecting is that you didn't change the name of the shape you create from your driver.

Jul 18, 2011 at 10:59 AM

Hey bertrandleroy,

well here's driver code... I'm not sure what I did wrong here...



using UberBody.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;

namespace UberBody.Drivers
    public class UberBodyDriver : ContentPartDriver<UberBodyPart>
        protected override DriverResult Display(
            UberBodyPart part, string displayType, dynamic shapeHelper) {
            return ContentShape("Parts_UberBody",
                                () => shapeHelper.Parts_UberBody(
                    ContentPart: part,
                    Lead: part.Lead,
                    Text: part.Text));

        protected override DriverResult Editor(
            UberBodyPart part, dynamic shapeHelper)

            return ContentShape("Parts_UberBody_Edit",
                () => shapeHelper.EditorTemplate(
                    TemplateName: "Parts/UberBody",
                    Model: part,
                    Prefix: Prefix));
        protected override DriverResult Editor(
            UberBodyPart part, IUpdateModel updater, dynamic shapeHelper)

            updater.TryUpdateModel(part, Prefix, null, null);
            return Editor(part, shapeHelper);

Jul 18, 2011 at 1:36 PM

You need to actually tell your driver to use the Summary shape based on the displayType passed to Display() - at the moment you are returning a Parts_UberBody shape regardless of the displayType parameter.

Jul 18, 2011 at 5:03 PM


I must have misread something in documentation what lead me to assume that part would be done automatically.

Anyway, thanks for your assistance.

You'll hear from me again, be sure! :-)