【发布时间】:2012-07-01 01:19:11
【问题描述】:
我似乎无法将其他数据存储在附加到用户的单独内容部分中。我做了以下事情:
- 创建了一个模块
- 在模块中,我为 ProfilePart 和 ProfilePartRecord 创建了一个模型
- 在迁移过程中,我为 ProfilePartRecord 创建了一个表(来自 ContentPartRecord 类型)
- 在迁移中,我通过设置 WithPart ProfilePart 更改了 User 的类型定义
- 我创建了一个驱动类,它有 2 种编辑方法,一种用于获取,一种用于发布(代码 sn-ps 如下
- 我还创建了一个处理程序,它为 ProfilePartRecord 类型的 profilePartRepository 添加存储过滤器
模块结构
- 驱动程序/ProfilePartDriver.cs
- 处理程序/ProfileHandler.cs
- 模型/ProfilePart.cs
- 模型/ProfilePartRecord.cs
- 视图/EditorTemplates/Parts/profile.cshtml
- Migrations.cs
- Placement.info
因为我认为问题出在驱动程序上。这是我的代码:
是否因为部件附加到用户而出错?还是我错过了其他东西。
公共类 ProfilePartDriver:ContentPartDriver {
protected override string Prefix
{
get { return "Profile"; }
}
//GET
protected override DriverResult Editor(ProfilePart part, dynamic shapeHelper)
{
return ContentShape("Parts_Profile_Edit", () =>
shapeHelper.EditorTemplate(TemplateName: "Parts/Profile", Model: part, Prefix: Prefix));
}
//POST
protected override DriverResult Editor(ProfilePart part, IUpdateModel updater, dynamic shapeHelper)
{
updater.TryUpdateModel(part, Prefix, null, null);
return Editor(part, shapeHelper);
}
}
【问题讨论】:
-
我会看看现有的配置文件模块之一,看看他们是如何做到的。
标签: orchardcms