mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding migration from previous version of navigation
--HG-- branch : 1.x
This commit is contained in:
@@ -1,9 +1,15 @@
|
|||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
using Orchard.Core.Contents.Extensions;
|
using Orchard.Core.Contents.Extensions;
|
||||||
|
using Orchard.Core.Navigation.Services;
|
||||||
using Orchard.Data.Migration;
|
using Orchard.Data.Migration;
|
||||||
|
|
||||||
namespace Orchard.Core.Navigation {
|
namespace Orchard.Core.Navigation {
|
||||||
public class Migrations : DataMigrationImpl {
|
public class Migrations : DataMigrationImpl {
|
||||||
|
private readonly IMenuService _menuService;
|
||||||
|
|
||||||
|
public Migrations(IMenuService menuService ) {
|
||||||
|
_menuService = menuService;
|
||||||
|
}
|
||||||
|
|
||||||
public int Create() {
|
public int Create() {
|
||||||
ContentDefinitionManager.AlterPartDefinition("MenuPart", builder => builder.Attachable());
|
ContentDefinitionManager.AlterPartDefinition("MenuPart", builder => builder.Attachable());
|
||||||
@@ -154,6 +160,21 @@ namespace Orchard.Core.Navigation {
|
|||||||
|
|
||||||
ContentDefinitionManager.AlterPartDefinition("NavigationPart", builder => builder.Attachable());
|
ContentDefinitionManager.AlterPartDefinition("NavigationPart", builder => builder.Attachable());
|
||||||
|
|
||||||
|
|
||||||
|
// create a Main Menu
|
||||||
|
var mainMenu = _menuService.Create("Main Menu");
|
||||||
|
|
||||||
|
// assign the Main Menu to all current menu items
|
||||||
|
foreach (var menuItem in _menuService.Get()) {
|
||||||
|
// if they don't have a position, then they are not displayed
|
||||||
|
if(string.IsNullOrWhiteSpace(menuItem.MenuPosition)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
menuItem.Menu = mainMenu.ContentItem.Record;
|
||||||
|
}
|
||||||
|
|
||||||
|
// at this point a widget should still be created to display the navigation
|
||||||
|
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user