Fix blog and page commands Homepage and Slug switches

--HG--
branch : autoroute
This commit is contained in:
randompete
2012-01-18 21:29:02 +00:00
parent f2b161211a
commit cbc1fee198
2 changed files with 16 additions and 4 deletions

View File

@@ -81,6 +81,16 @@ namespace Orchard.Blogs.Commands {
blog.As<MenuPart>().MenuPosition = _menuService.Get().Select(menuPart => menuPart.MenuPosition).Max() + 1 + ".0";
blog.As<MenuPart>().MenuText = MenuText;
}
if (Homepage) {
dynamic dblog = blog;
if (dblog.AutoroutePart != null) {
dblog.AutoroutePart.UseCustomPattern = true;
dblog.AutoroutePart.CustomPattern = "";
}
}
_contentManager.Create(blog);
Context.Output.WriteLine(T("Blog created successfully"));

View File

@@ -57,10 +57,12 @@ namespace Orchard.Pages.Commands {
// (PH:Autoroute) Hackish way to leave Slug and Homepage switches intact without requiring a dependency on Autoroute. This may throw an Exception with
// no AutoroutePart. But it means that normal setup recipes will still be able to give you a homepage without issue.
dynamic dpage = page;
if (dpage.AutoroutePart != null && (Homepage || !String.IsNullOrWhiteSpace(Slug))) {
dpage.AutoroutePart.UseCustomPattern = true;
dpage.AutoroutePart.CustomPattern = Slug;
if (Homepage || !String.IsNullOrWhiteSpace(Slug)) {
dynamic dpage = page;
if (dpage.AutoroutePart != null) {
dpage.AutoroutePart.UseCustomPattern = true;
dpage.AutoroutePart.CustomPattern = Homepage?"":Slug;
}
}
var text = String.Empty;