mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +08:00
Store default location for the "HasComments[Container]" part in initial settings
--HG-- branch : dev
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
using Orchard.Data.Migration;
|
||||
|
||||
namespace Orchard.Comments.DataMigrations {
|
||||
@@ -59,5 +63,24 @@ namespace Orchard.Comments.DataMigrations {
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
public int UpdateFrom2() {
|
||||
ContentDefinitionManager.AlterPartDefinition(typeof(HasComments).Name, cfg => cfg
|
||||
.WithLocation(new Dictionary<string, ContentLocation> {
|
||||
{"Default", new ContentLocation { Zone = "primary", Position = "before.5" }},
|
||||
{"Detail", new ContentLocation { Zone = "primary", Position = "after.5" }},
|
||||
{"SummaryAdmin", new ContentLocation { Zone = "meta", Position = null }},
|
||||
{"Summary", new ContentLocation { Zone = "meta", Position = "5" }},
|
||||
{"Editor", new ContentLocation { Zone = "primary", Position = "10" }},
|
||||
}));
|
||||
|
||||
ContentDefinitionManager.AlterPartDefinition(typeof(HasCommentsContainer).Name, cfg => cfg
|
||||
.WithLocation(new Dictionary<string, ContentLocation> {
|
||||
{"SummaryAdmin", new ContentLocation { Zone = "meta", Position = null }},
|
||||
{"Summary", new ContentLocation { Zone = "meta", Position = null }},
|
||||
}));
|
||||
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
@@ -12,12 +12,10 @@ namespace Orchard.Comments.Drivers {
|
||||
public class HasCommentsContainerDriver : ContentPartDriver<HasCommentsContainer> {
|
||||
protected override DriverResult Display(HasCommentsContainer part, string displayType) {
|
||||
if (displayType == "SummaryAdmin") {
|
||||
var location = part.GetLocation("SummaryAdmin", "meta", null);
|
||||
return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.CountAdmin").Location(location);
|
||||
return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.CountAdmin").Location(part.GetLocation("SummaryAdmin"));
|
||||
}
|
||||
else if (displayType.Contains("Summary")) {
|
||||
var location = part.GetLocation("Summary", "meta", null);
|
||||
return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.Count").Location(location);
|
||||
return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.Count").Location(part.GetLocation("Summary"));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@@ -16,38 +16,29 @@ namespace Orchard.Comments.Drivers {
|
||||
// todo: (heskew) need to be more flexible with displaying parts somehow. e.g. where should the...
|
||||
// comment count go in any given skin or what if the skin builder doesn't want the count
|
||||
if (displayType.StartsWith("Detail")) {
|
||||
//return Combined(
|
||||
// ContentPartTemplate(part, "Parts/Comments.Count").Location("body", "above.5"),
|
||||
// ContentPartTemplate(part, "Parts/Comments.HasComments").Location("body", "below.5"));
|
||||
var location = part.GetLocation("Detail", "primary", "after.5");
|
||||
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(location);
|
||||
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(part.GetLocation("Detail"));
|
||||
}
|
||||
else if (displayType == "SummaryAdmin") {
|
||||
var location = part.GetLocation("SummaryAdmin", "meta", null);
|
||||
var model = new CommentCountViewModel(part);
|
||||
return ContentPartTemplate(model, "Parts/Comments.CountAdmin").Location(location);
|
||||
return ContentPartTemplate(model, "Parts/Comments.CountAdmin").Location(part.GetLocation("SummaryAdmin"));
|
||||
}
|
||||
else if (displayType.Contains("Summary")) {
|
||||
var location = part.GetLocation("Summary", "meta", "5");
|
||||
var model = new CommentCountViewModel(part);
|
||||
return ContentPartTemplate(model, "Parts/Comments.Count").Location(location);
|
||||
return ContentPartTemplate(model, "Parts/Comments.Count").Location(part.GetLocation("Summary"));
|
||||
}
|
||||
else {
|
||||
var location = part.GetLocation(displayType, "primary", "before.5");
|
||||
var model = new CommentCountViewModel(part);
|
||||
return ContentPartTemplate(model, "Parts/Comments.Count").Location(location);
|
||||
return ContentPartTemplate(model, "Parts/Comments.Count").Location(part.GetLocation(displayType));
|
||||
}
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(HasComments part) {
|
||||
var location = part.GetLocation("Editor", "primary", "10");
|
||||
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(location);
|
||||
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(part.GetLocation("Editor"));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(HasComments part, IUpdateModel updater) {
|
||||
var location = part.GetLocation("Editor", "primary", "10");
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(location);
|
||||
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(part.GetLocation("Editor"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,4 +8,5 @@ description: The comments system implemented by this module can be applied to ar
|
||||
features:
|
||||
Orchard.Comments:
|
||||
Description: Standard content item comments.
|
||||
Dependencies: Settings
|
||||
Category: Social
|
||||
|
@@ -8,5 +8,5 @@ description: The tags module is providing basic tagging for arbitrary content ty
|
||||
features:
|
||||
Orchard.Tags:
|
||||
Description: Tag a content item.
|
||||
Dependencies: ContentsLocation
|
||||
Dependencies: Settings
|
||||
Category: Navigation
|
||||
|
Reference in New Issue
Block a user