mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Add 5th location type "Default"
This is the fallback option is no location is given for a specific display name. --HG-- branch : dev
This commit is contained in:
parent
f4f0651c22
commit
34ee0be5ac
@ -18,6 +18,11 @@ namespace Orchard.Core.ContentsLocation.Models {
|
||||
if (this.TryGetValue(location, out result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (this.TryGetValue("Default", out result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return new ContentLocation { Zone = defaultZone, Position = defaultPosition };
|
||||
}
|
||||
}
|
||||
@ -28,11 +33,13 @@ namespace Orchard.Core.ContentsLocation.Models {
|
||||
}
|
||||
|
||||
public static ContentLocation GetLocation<TContent>(this TContent part, string locationName, string defaultZone, string defaultPosition) where TContent : ContentPart {
|
||||
var typePartLocation = part.TypePartDefinition.Settings.GetModel<LocationSettings>().Get(locationName);
|
||||
if (typePartLocation.Position == null && typePartLocation.Zone == null) {
|
||||
return part.PartDefinition.Settings.GetModel<LocationSettings>().Get(locationName, defaultZone, defaultPosition);
|
||||
}
|
||||
return typePartLocation;
|
||||
// Get the specific location from the part in the type context
|
||||
var location = part.TypePartDefinition.Settings.GetModel<LocationSettings>().Get(locationName);
|
||||
if (location.Position != null || location.Zone != null)
|
||||
return location;
|
||||
|
||||
// Get the specific location from the part definition
|
||||
return part.PartDefinition.Settings.GetModel<LocationSettings>().Get(locationName, defaultZone, defaultPosition);
|
||||
}
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ namespace Orchard.Core.ContentsLocation.Settings {
|
||||
public Localizer T { get; set; }
|
||||
|
||||
private IEnumerable<LocationDefinition> GetPredefinedLocations() {
|
||||
yield return new LocationDefinition { Name = "Default", DisplayName = T("Default location (i.e. fallback if no specific override)") };
|
||||
yield return new LocationDefinition { Name = "Detail", DisplayName = T("Location in a \"Detail\" screen") };
|
||||
yield return new LocationDefinition { Name = "Editor", DisplayName = T("Location in a \"Editor\" screen") };
|
||||
yield return new LocationDefinition { Name = "Summary", DisplayName = T("Location in a \"Summary\" screen (Front-end)") };
|
||||
|
@ -10,9 +10,7 @@ namespace Orchard.Core.PublishLater.DataMigrations {
|
||||
public int Create() {
|
||||
ContentDefinitionManager.AlterPartDefinition(typeof(PublishLaterPart).Name, cfg => cfg
|
||||
.WithLocation(new Dictionary<string, ContentLocation> {
|
||||
{"Display", new ContentLocation { Zone = "metadata", Position = "1" }},
|
||||
{"Summary", new ContentLocation { Zone = "metadata", Position = "1" }},
|
||||
{"SummaryAdmin", new ContentLocation { Zone = "metadata", Position = "1" }},
|
||||
{"Default", new ContentLocation { Zone = "metadata", Position = "1" }},
|
||||
{"Editor", new ContentLocation { Zone = "secondary", Position = "1" }}
|
||||
}));
|
||||
return 1;
|
||||
|
@ -32,8 +32,7 @@ namespace Orchard.Core.PublishLater.Drivers {
|
||||
var model = new PublishLaterViewModel(part) {
|
||||
ScheduledPublishUtc = part.ScheduledPublishUtc.Value
|
||||
};
|
||||
var location = part.GetLocation(displayType, "metadata", "1");
|
||||
return ContentPartTemplate(model, "Parts/PublishLater.Metadata").LongestMatch(displayType, "Summary", "SummaryAdmin").Location(location);
|
||||
return ContentPartTemplate(model, "Parts/PublishLater.Metadata").LongestMatch(displayType, "Summary", "SummaryAdmin").Location(part.GetLocation(displayType));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(PublishLaterPart part) {
|
||||
@ -67,8 +66,7 @@ namespace Orchard.Core.PublishLater.Drivers {
|
||||
}
|
||||
}
|
||||
|
||||
var location = part.GetLocation("Editor", "secondary", "1");
|
||||
return ContentPartTemplate(model, "Parts/PublishLater", TemplatePrefix).Location(location);
|
||||
return ContentPartTemplate(model, "Parts/PublishLater", TemplatePrefix).Location(part.GetLocation("Editor"));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user