2011-05-31 87 views
3

我一直在为Orchard构建模块;基于N-N relationship tutorial。在我完成项目并改变名称空间之后,我开始了各种类和变量名称的工作,因为我对各种名称进行了各种不同的假设,而这些假设并没有出现。Orchard CMS模块仪表板中的重复模块条目

因为这个重命名行使模块( “定义列表”)两次显示了在模块仪表板:

Screenshot of 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: 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

通过在“作者:Richard Slater”之后添加“Category:Content”,它现在在相同类别中出现两次,但我仍然不明白为什么Module和Feature显示为单独的项目。 – 2011-05-31 13:10:51

回答

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

您可以使用清单文件的功能部分,如果你喜欢,但问题是最有可能的范围内的第一个条目的名称功能部分。如果你的模块命名空间是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中找到。