Incremental work on localized menu items.

This commit is contained in:
Sipke Schoorstra
2016-04-12 18:53:51 +02:00
parent b9c610b770
commit a7199348bd
3 changed files with 23 additions and 2 deletions

View File

@@ -1,10 +1,30 @@
using Orchard.Core.Navigation.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Core.Navigation.Models;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Navigation.Handlers {
public class MenuItemPartHandler : ContentHandler {
public MenuItemPartHandler() {
Filters.Add(new ActivatingFilter<MenuItemPart>("MenuItem"));
OnUpdated<MenuItemPart>(AttachMenu);
}
private void AttachMenu(UpdateContentContext context, MenuItemPart part) {
// Check if the menu item is localizable.
var localizableAspect = part.As<ILocalizableAspect>();
if (localizableAspect == null)
return;
// Check if this is the master content item.
if (localizableAspect.MasterContentItem == part)
return;
// This is a localized version of the menu item, so ensure it is bound to the same Menu.
var menuPart = part.As<MenuPart>();
menuPart.Menu = localizableAspect.MasterContentItem.As<MenuPart>().Menu;
}
}
}

View File

@@ -41,7 +41,7 @@ namespace Orchard.Localization.Controllers {
if (masterLocalizationPart == null)
return HttpNotFound();
// Check is current item stll exists, and redirect.
// Check if current item still exists, and redirect.
var existingTranslation = _localizationService.GetLocalizedContentItem(masterContentItem, to);
if (existingTranslation != null) {
var existingTranslationMetadata = _contentManager.GetItemMetadata(existingTranslation);

View File

@@ -1,5 +1,6 @@
namespace Orchard.ContentManagement.Aspects {
public interface ILocalizableAspect : IContent {
string Culture { get ; }
IContent MasterContentItem { get; }
}
}