Orchard CMS 模块仪表板中的重复模块条目
我一直在为 Orchard 构建一个模块;基于NN 关系教程。在项目开始工作后,我检查并更改了命名空间、各种类和变量名称,因为我对名称做出了各种假设,但这些假设并没有成功。
由于此重命名练习,模块(“定义列表”)在模块仪表板中显示两次:
这是my 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
我想不出项目中可以指定不同类别的任何地方。
迁移.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;
}
}
I have been working through building a module for Orchard; based upon the N-N relationship tutorial. After getting the project working once I went through and changed the namespace, various classes and variable names as I had made various assumptions about names that did not pan out.
Since this renaming exercise the Module ("Definition List") shows up twice in the modules dashboard:
Here is my 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
I can't think of anywhere in the project that would specify a different category.
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;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我似乎对 module.txt 进行了过度设计,因为删除文件的“功能”部分解决了重复问题。除了一些附加字段和一些重新排序之外,还有我的新工作 module.txt:
I appear to have over-engineered my module.txt, as removing the "Features" section of the file sorts out the duplication issue. Along with some additional fields and some reordering here is my new working module.txt:
如果您愿意,您可以使用清单文件的功能部分,但问题很可能是功能部分中第一个条目的名称。如果您的模块命名空间是 My.Orchard.DefintionList,则清单应如下所示:
请注意,该功能被命名为“My.Orchard.DefinitionList”,而不是您最初使用的“定义列表”。有关清单文件的其他信息可以在 Orchard 文档中找到。
You can use the features section of your manifest file if you like but the problem was most likely the name of the first entry within the features section. If your module namespace was My.Orchard.DefintionList, then the manifest should appear as follows:
Note that the feature is named "My.Orchard.DefinitionList" instead of "Definition List" as you originally used. Additional information regarding manifest files can be found in the Orchard documentation.