0
votes

I am trying to build a very simple widget with two input fields Name and Email address. Right now I am following http://www.deepcode.co.uk/search?q=how+to+build+a+widget+without+a+model+in+Orchard.

Migration.cs

public int UpdateFrom22()
{
    ContentDefinitionManager.AlterTypeDefinition("QuickLinkWidget", builder => builder
    .WithPart("QuickLinkWidgetPart")
    .WithPart("CommonPart")
    .WithPart("WidgetPart")
    .WithSetting("Stereotype", "Widget"));

    return 23;
}

ContentPartRecord (Models/QuickLinkWidgetRecord.cs)

public class QuickLinkWidgetRecord : ContentPartRecord

{
    //We shall not define any property for this class.
    //We shall not create any HANDLER for this widget because we do not need to store any data to our database.
}

ContentPart: (Models/QuickLinkWidgetPart.cs)

public class QuickLinkWidgetPart : ContentPart<QuickLinkWidgetRecord>
{
    //Again we shall not definte any Record property here......
    //We shall not create any HANDLER for this widget because we do not need to store any data to our database.
}

Handler

Did not define any as I don't have deal with any repository.

Driver: ((Models/QuickLinkWidgetDriver.cs))

public class QuickLinkWidgetDriver : ContentPartDriver<QuickLinkWidgetPart>

{
    override DriverResult Display(QuickLinkWidgetPart part, string displayType, dynamic shapeHelper)
    {
    //We do not have any property defined in Model class.
    //So we don't have to assign any Default values to anything!
    //We shall just return a SHAPE of the widget
    }
}

Placement.info:

<Place Widgets_QuickLinkWidget="AsideFirst:1" />

And finally the View: Views/Widgets/QuickLinkWidget.cshtml

@using Emfluence.Intrust.Models;

@model Contact

<h2>Our Side link widget</h2>

Nothing extra I added in my View

Please help me understanding what I am doing wrong. Why I am not able to see the widget rendered at all? I am stuck with it for the last 3 days!, just want to see it rendering first!

Thanks in advance fro your help

1
Your driver doesn't have anything in it? And your placement needs to say to show your part, not the widget. Then create the widget from the dashboard.Hazza
Can you add any example, I have the same problem.Assassin

1 Answers

0
votes

I had similar issue and i got it working by changing some setting on my placement.info file...in your case try this

<Place Widgets_QuickLinkWidget="Content" />