mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 03:14:10 +08:00
Preventing Blueprints from being selectable as base elements.
This commit is contained in:
@@ -57,7 +57,7 @@ namespace Orchard.Layouts.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult Browse() {
|
||||
var categories = _elementManager.GetCategories(DescribeElementsContext.Empty).ToArray();
|
||||
var categories = RemoveBlueprints(_elementManager.GetCategories(DescribeElementsContext.Empty)).ToArray();
|
||||
var viewModel = new BrowseElementsViewModel {
|
||||
Categories = categories
|
||||
};
|
||||
@@ -223,6 +223,21 @@ namespace Orchard.Layouts.Controllers {
|
||||
return context;
|
||||
}
|
||||
|
||||
private IEnumerable<CategoryDescriptor> RemoveBlueprints(IEnumerable<CategoryDescriptor> categories) {
|
||||
foreach (var descriptor in categories) {
|
||||
var d = new CategoryDescriptor(descriptor.Name, descriptor.DisplayName, descriptor.Description, descriptor.Position);
|
||||
|
||||
foreach (var element in descriptor.Elements) {
|
||||
if (!element.StateBag.ContainsKey("Blueprint")) {
|
||||
d.Elements.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
if(d.Elements.Any())
|
||||
yield return d;
|
||||
}
|
||||
}
|
||||
|
||||
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
|
||||
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
|
||||
}
|
||||
|
Reference in New Issue
Block a user