mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Allowing templates to override themes' shapes
This commit is contained in:
@@ -35,12 +35,24 @@ namespace Orchard.Templates.Services {
|
||||
})
|
||||
.ToList();
|
||||
|
||||
// Use a fake theme descriptor which will ensure the shape is used over
|
||||
// any other extension. It's also necessary to define them in the Admin
|
||||
// theme in order to process tokens
|
||||
|
||||
var fakeThemeDescriptor = new FeatureDescriptor {
|
||||
Id = "", // so that the binding is not filtered out
|
||||
Priority = 10, // so that it's higher than the themes' priority
|
||||
Extension = new ExtensionDescriptor {
|
||||
ExtensionType = DefaultExtensionTypes.Theme, // so that the binding is overriding modules
|
||||
}
|
||||
};
|
||||
|
||||
foreach (var record in shapes) {
|
||||
_templateProvider.Set(record.Name, record.Template);
|
||||
var shapeType = AdjustName(record.Name);
|
||||
|
||||
builder.Describe(shapeType)
|
||||
.From(new Feature { Descriptor = Feature.Descriptor })
|
||||
.From(new Feature { Descriptor = fakeThemeDescriptor })
|
||||
.BoundAs("Template::" + shapeType,
|
||||
descriptor => context => {
|
||||
var template = _templateProvider.Get(record.Name);
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Orchard.DisplayManagement.Descriptors {
|
||||
if (DefaultExtensionTypes.IsTheme(extensionType)) {
|
||||
// alterations from themes must be from the given theme or a base theme
|
||||
var featureName = alteration.Feature.Descriptor.Id;
|
||||
return featureName == themeName || IsBaseTheme(featureName, themeName);
|
||||
return String.IsNullOrEmpty(featureName) || featureName == themeName || IsBaseTheme(featureName, themeName);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user