Orchard CMS模块仪表板中存在重复的模块条目

3

我一直在构建一个Orchard模块,基于N-N关系教程。在将项目工作一次后,我更改了命名空间、各种类和变量名称,因为我做出了一些不成立的假设。

自从进行了这个重命名练习之后,模块(“定义列表”)在模块仪表板中显示了两次:

Modules Dashboard截图

这是我的module.txt:

Name: Definition List
AntiForgery: enabled
Author: Richard Slater
Website: http://www.richard-slater.co.uk/
Version: 0.2
OrchardVersion: 1.1
Description: 模块部分,用于提供可选择的定义列表作为复选框
Features:
    Definition List:
        Description: 添加定义列表部分
        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;
    }
}

在“作者:Richard Slater”之后添加“类别:内容”,它现在出现在同一类别中两次,但我仍然不明白为什么模块和功能显示为单独的项目。 - Richard Slater
2个回答

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",而不是您最初使用的"Definition List"。有关清单文件的其他信息,请参阅Orchard文档

1

我似乎在我的module.txt上进行了过度设计,因为删除文件中的“Features”部分解决了重复问题。除了一些额外的字段和一些重新排序之外,这是我的新工作module.txt:

名称:定义列表
反伪造:启用
作者:Richard Slater
网站:http://www.richard-slater.co.uk/
版本:0.2
Orchard版本:1.1
描述:提供一个可选择的定义列表作为复选框。
功能描述:定义列表部分。
类别:内容

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接