我一直在为Orchard建立一个模块;基于N-N relationship tutorial。在我完成项目工作之后,我经历了更改命名空间,各种类和变量名称,因为我对名称没有做出各种假设。
由于此重命名练习,模块(“定义列表”)在模块仪表板中显示两次:
这是我的module.txt:
Name: Definition List AntiForgery: enabled Author: Richard Slater Website: http://www.richard-slater.co.uk/ Version: 0.2 OrchardVersion: 1.1 Description: Module Part to provision a selectable list of definitions as check boxes Features: Definition List: Description: Adds Definition List Part Category: Content
我无法想到项目中指定不同类别的任何地方。
Migrations.cs:
public class Migrations : DataMigrationImpl {
private readonly IRepository<DefinitionRecord> _definitionListRepository;
private readonly IEnumerable<DefinitionRecord> _sampleRecords = new List<DefinitionRecord> {
new DefinitionRecord { Term = "Term A", Definition = "This is the definition for Term A" },
new DefinitionRecord { Term = "Term B", Definition = "This is the definition for Term B" },
new DefinitionRecord { Term = "Term C", Definition = "This is the definition for Term C" }
};
public Migrations(IRepository<DefinitionRecord> definitionListRepository) {
_definitionListRepository = definitionListRepository;
}
public int Create()
{
SchemaBuilder.CreateTable("DefinitionListPartRecord",
table => table
.ContentPartRecord()
);
SchemaBuilder.CreateTable("DefinitionRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("Term")
.Column<string>("Definition")
);
SchemaBuilder.CreateTable("ContentDefinitionRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<int>("DefinitionListPartRecord_Id")
.Column<int>("DefinitionRecord_Id")
);
ContentDefinitionManager.AlterPartDefinition(
"DefinitionListPart",
builder => builder.Attachable());
if (_definitionListRepository == null)
throw new InvalidOperationException("Cannot find the Definition List Repository");
foreach (var entity in _sampleRecords) {
_definitionListRepository.Create(entity);
}
return 1;
}
}
答案 0 :(得分:1)
我似乎过度设计了我的module.txt,因为删除文件的“功能”部分可以解决重复问题。除了一些额外的字段和一些重新排序,这是我的新工作module.txt:
Name: Definition List AntiForgery: enabled Author: Richard Slater Website: http://www.richard-slater.co.uk/ Version: 0.2 OrchardVersion: 1.1 Description: Provision a selectable list of definitions as check boxes. FeatureDescription: Definition List Part. Category: Content
答案 1 :(得分:1)
如果您愿意,可以使用清单文件的功能部分,但问题很可能是功能部分中第一个条目的名称。如果您的模块名称空间是My.Orchard.DefintionList,那么清单应如下所示:
Name: Definition List
AntiForgery: enabled
Author: Richard Slater
Website: http://www.richard-slater.co.uk/
Version: 0.2
OrchardVersion: 1.1
Description: Module Part to provision a selectable list of definitions as check boxes
Features:
My.Orchard.DefinitionList:
Description: Adds Definition List Part
Category: Content
请注意,该功能名称为“My.Orchard.DefinitionList”,而不是您最初使用的“定义列表”。有关清单文件的其他信息可以在Orchard documentation。
中找到