mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-18 19:51:45 +08:00
Disabling the Orchard.Pages module by default and adjusted the page content type configured during setup to be a page-like content type.
- also added a RoutableHomePageProvider to support a routable item as the home page --HG-- branch : dev
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using System.Web.Mvc;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Routable.Models;
|
||||
using Orchard.Core.Routable.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Mvc.Results;
|
||||
using Orchard.Services;
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Core.Routable.Services {
|
||||
[UsedImplicitly]
|
||||
public class RoutableHomePageProvider : IHomePageProvider {
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public RoutableHomePageProvider(IOrchardServices services, IContentManager contentManager) {
|
||||
_contentManager = contentManager;
|
||||
Services = services;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public IOrchardServices Services { get; private set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public string GetProviderName() {
|
||||
return "RoutableHomePageProvider";
|
||||
}
|
||||
|
||||
public ActionResult GetHomePage(int itemId) {
|
||||
var contentItem = _contentManager.Get(itemId, VersionOptions.Published);
|
||||
if (contentItem == null || !contentItem.Is<IsRoutable>())
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new RoutableDisplayViewModel {
|
||||
Routable = _contentManager.BuildDisplayModel<IRoutableAspect>(contentItem.As<IsRoutable>(), "Detail")
|
||||
};
|
||||
|
||||
return new ViewResult {
|
||||
ViewName = "~/Core/Routable/Views/Item/Display.ascx",
|
||||
ViewData = new ViewDataDictionary<RoutableDisplayViewModel>(model)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,6 @@ namespace Orchard.Setup.Services {
|
||||
"TinyMce",
|
||||
"Orchard.Modules",
|
||||
"Orchard.Themes",
|
||||
"Orchard.Pages",
|
||||
"Orchard.Blogs",
|
||||
"Orchard.Comments",
|
||||
"Orchard.Tags",
|
||||
@@ -181,7 +180,7 @@ namespace Orchard.Setup.Services {
|
||||
|
||||
var contentDefinitionManager = environment.Resolve<IContentDefinitionManager>();
|
||||
contentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg.DisplayedAs("Blog Post").WithPart("HasComments").WithPart("HasTags").WithPart("Localized").Indexed());
|
||||
contentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg.DisplayedAs("Page").WithPart("HasComments").WithPart("HasTags").WithPart("Localized").Indexed());
|
||||
contentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg.DisplayedAs("Page").WithPart("CommonAspect").WithPart("IsRoutable").WithPart("BodyAspect").WithPart("HasComments").WithPart("HasTags").WithPart("Localized").Indexed());
|
||||
contentDefinitionManager.AlterTypeDefinition("SandboxPage", cfg => cfg.DisplayedAs("Sandbox Page").WithPart("HasComments").WithPart("HasTags").WithPart("Localized").Indexed());
|
||||
contentDefinitionManager.AlterPartDefinition("BodyAspect", cfg => cfg.WithSetting("BodyPartSettings.FlavorDefault", BodyPartSettings.FlavorDefaultDefault));
|
||||
|
||||
@@ -195,7 +194,7 @@ namespace Orchard.Setup.Services {
|
||||
page.As<HasComments>().CommentsShown = false;
|
||||
}
|
||||
contentManager.Publish(page);
|
||||
siteSettings.Record.HomePage = "PageHomePageProvider;" + page.Id;
|
||||
siteSettings.Record.HomePage = "RoutableHomePageProvider;" + page.Id;
|
||||
|
||||
// add a menu item for the shiny new home page
|
||||
var menuItem = contentManager.Create("MenuItem");
|
||||
|
||||
Reference in New Issue
Block a user