mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 12:03:51 +08:00
#18602: Fixing Blog recipe homepage
Work Item: 18602 --HG-- branch : 1.x
This commit is contained in:
@@ -44,6 +44,9 @@ namespace Orchard.Blogs.Commands {
|
|||||||
[OrchardSwitch]
|
[OrchardSwitch]
|
||||||
public string Owner { get; set; }
|
public string Owner { get; set; }
|
||||||
|
|
||||||
|
[OrchardSwitch]
|
||||||
|
public string Slug { get; set; }
|
||||||
|
|
||||||
[OrchardSwitch]
|
[OrchardSwitch]
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
|
|
||||||
@@ -57,7 +60,7 @@ namespace Orchard.Blogs.Commands {
|
|||||||
public bool Homepage { get; set; }
|
public bool Homepage { get; set; }
|
||||||
|
|
||||||
[CommandName("blog create")]
|
[CommandName("blog create")]
|
||||||
[CommandHelp("blog create /Title:<title> [/Owner:<username>] [/Description:<description>] [/MenuText:<menu text>] [/Homepage:true|false]\r\n\t" + "Creates a new Blog")]
|
[CommandHelp("blog create [/Slug:<slug>] /Title:<title> [/Owner:<username>] [/Description:<description>] [/MenuText:<menu text>] [/Homepage:true|false]\r\n\t" + "Creates a new Blog")]
|
||||||
[OrchardSwitches("Title,Owner,Description,MenuText,Homepage")]
|
[OrchardSwitches("Title,Owner,Description,MenuText,Homepage")]
|
||||||
public void Create() {
|
public void Create() {
|
||||||
if (String.IsNullOrEmpty(Owner)) {
|
if (String.IsNullOrEmpty(Owner)) {
|
||||||
@@ -82,15 +85,14 @@ namespace Orchard.Blogs.Commands {
|
|||||||
blog.As<MenuPart>().MenuText = MenuText;
|
blog.As<MenuPart>().MenuText = MenuText;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Homepage) {
|
if (Homepage || !String.IsNullOrWhiteSpace(Slug)) {
|
||||||
dynamic dblog = blog;
|
dynamic dblog = blog;
|
||||||
if (dblog.AutoroutePart != null) {
|
if (dblog.AutoroutePart != null) {
|
||||||
dblog.AutoroutePart.UseCustomPattern = true;
|
dblog.AutoroutePart.UseCustomPattern = true;
|
||||||
dblog.AutoroutePart.CustomPattern = "";
|
dblog.AutoroutePart.CustomPattern = Homepage ? "/" : Slug;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_contentManager.Create(blog);
|
_contentManager.Create(blog);
|
||||||
|
|
||||||
Context.Output.WriteLine(T("Blog created successfully"));
|
Context.Output.WriteLine(T("Blog created successfully"));
|
||||||
|
|||||||
Reference in New Issue
Block a user