gpt4 book ai didi

.net - Orchard CMS 模块仪表板中的重复模块条目

转载 作者:行者123 更新时间:2023-12-02 02:25:22 24 4
gpt4 key购买 nike

我一直在为 Orchard 构建一个模块;基于 N-N relationship tutorial .在让项目运行后,我完成并更改了命名空间、各种类和变量名称,因为我对名称做出了各种假设,但没有成功。

自从这次重命名练习以来,模块(“定义列表”)在模块仪表板中出现了两次:

Screenshot of Modules Dashboard

这是我的 module.txt:

Name: Definition ListAntiForgery: enabledAuthor: Richard SlaterWebsite: http://www.richard-slater.co.uk/Version: 0.2OrchardVersion: 1.1Description: Module Part to provision a selectable list of definitions as check boxesFeatures:    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;
}
}

最佳答案

我似乎过度设计了我的 module.txt,因为删除文件的“功能”部分解决了重复问题。除了一些额外的字段和一些重新排序,这里还有我的新工作 module.txt:

Name: Definition ListAntiForgery: enabledAuthor: Richard SlaterWebsite: http://www.richard-slater.co.uk/Version: 0.2OrchardVersion: 1.1Description: Provision a selectable list of definitions as check boxes.FeatureDescription: Definition List Part.Category: Content

关于.net - Orchard CMS 模块仪表板中的重复模块条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6188058/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com