Can't get widget to display

Topics: General, Troubleshooting
Apr 10, 2011 at 6:49 PM

Hi,

I'm having some trouble getting a widget to display in the content zone in orchard 1.1. The widget doesn't have a ContentPartRecord, it's just form fields that post back to a controller in the module. I've defined the widget as this:

 public int Create()
        {

            ContentDefinitionManager.AlterPartDefinition(typeof(EmailSignupPart).Name, cfg=> cfg.Attachable());

            ContentDefinitionManager.AlterTypeDefinition(
                "EmailSignupWidget", cfg => 
                    cfg.WithPart("WidgetPart")
                    .WithPart("CommonPart")
                    .WithSetting("Stereotype", "Widget"));

            return 1;
        }

I can add it in the widgets section in the admin menu, but it seems the driver is never called, and the HTML in my view doesn't show. I just want the driver to return the view:
    public class EmailSignupDriver : ContentPartDriver<EmailSignupPart>
    {
        protected override DriverResult Display(EmailSignupPart part, string displayType, dynamic shapeHelper)
        {
            return ContentShape("Parts_EmailSignup", () => shapeHelper.Parts_EmailSignup());
        }
    }

It should be pretty straight forward, but I'm stumped as to why it won't show. The html container for the widget is rendered, but not it's view:

    <div class="widget-control">
      <div class="manage-actions"><a href="/OrchardLocal/Admin/Widgets/EditWidget/13?ReturnUrl=%2FOrchardLocal%2F">Edit</a></div>
        <article class="widget-email-signup-widget widget"><!-- why is this empty? --></article>
      </div>
    </div>

I have the placement file too:
<Placement>
    <Place Parts_EmailSignup="Content:1"/>
</Placement>

 

 

Coordinator
Apr 10, 2011 at 6:53 PM

Well, yes, it seems pretty straightforward ;) You forgot to add the EmailSignupPart to your type.

Apr 10, 2011 at 7:35 PM

Yep, that was it, I just needed a new pair of eyes. Thanks