If MenuPart is a ContentMenuItem, check if the content is published before adding it to the NavigationBuilder. (#8653)

This commit is contained in:
Andrea Piovanelli
2023-03-17 09:11:09 +01:00
committed by GitHub
parent 9728831556
commit 7ac17272d2

View File

@@ -23,6 +23,15 @@ namespace Orchard.Core.Navigation.Services {
if (menuPart != null) { if (menuPart != null) {
var part = menuPart; var part = menuPart;
var showItem = true;
// If the menu item is a ContentMenuItemPart (from Orchard.ContentPicker), check the ContentItem is published.
// If there is no published version of the ContentItem, the item must not be added to NavigationBuilder.
var cmip = ((dynamic)part).ContentMenuItemPart;
if (cmip != null) {
showItem = cmip.Content != null;
}
if (showItem) {
string culture = null; string culture = null;
// fetch the culture of the content menu item, if any // fetch the culture of the content menu item, if any
var localized = part.As<ILocalizableAspect>(); var localized = part.As<ILocalizableAspect>();
@@ -38,4 +47,5 @@ namespace Orchard.Core.Navigation.Services {
} }
} }
} }
}
} }