0

我正在尝试使用两个输入字段名称和电子邮件地址构建一个非常简单的小部件。现在我正在关注http://www.deepcode.co.uk/search?q=how+to+build+a+widget+without+a+model+in+Orchard

迁移.cs

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

    return 23;
}

ContentPartRecord (模型/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.
}

内容部分:(模型/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.
}

处理程序

没有定义任何因为我没有处理任何存储库。

驱动程序:((模型/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
    }
}

安置信息:

<Place Widgets_QuickLinkWidget="AsideFirst:1" />

最后是视图:Views/Widgets/QuickLinkWidget.cshtml

@using Emfluence.Intrust.Models;

@model Contact

<h2>Our Side link widget</h2>

我在视图中没有添加任何额外内容

请帮助我理解我做错了什么。为什么我根本看不到呈现的小部件?在过去的 3 天里,我一直坚持使用它!只想先看看它的渲染!

提前感谢您的帮助

4

1 回答 1

0

我有类似的问题,我通过更改我的placement.info文件上的一些设置来让它工作......在你的情况下试试这个

<Place Widgets_QuickLinkWidget="Content" />
于 2015-09-15T22:34:30.727 回答