开发者

Duplicate module entry in Orchard CMS Modules Dashboard

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:

Duplicate module entry in Orchard CMS 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()
    {
        SchemaBuilde开发者_StackOverflowr.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 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:

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


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:

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

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜