2011-05-31 84 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中找到。