mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 02:44:52 +08:00
Adding drop down list to select the blog for BLogArchiveWidget
--HG-- branch : dev extra : transplant_source : %3AAU%C1%80%07%8E72%83%5B%E4Yj%A0%DF._%91%80
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using Orchard.Blogs.Models;
|
||||
using System.Linq;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.Blogs.ViewModels;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
|
||||
@@ -28,12 +30,21 @@ namespace Orchard.Blogs.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BlogArchivesPart part, dynamic shapeHelper) {
|
||||
var viewModel = new BlogArchivesViewModel {
|
||||
Slug = part.ForBlog,
|
||||
Blogs = _blogService.Get().ToList().OrderBy(b => b.Name)
|
||||
};
|
||||
|
||||
return ContentShape("Parts_Blogs_BlogArchives_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Blogs.BlogArchives", Model: part, Prefix: Prefix));
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Blogs.BlogArchives", Model: viewModel, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BlogArchivesPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
var viewModel = new BlogArchivesViewModel();
|
||||
if (updater.TryUpdateModel(viewModel, Prefix, null, null)) {
|
||||
part.ForBlog = viewModel.Slug;
|
||||
}
|
||||
|
||||
return Editor(part, shapeHelper);
|
||||
}
|
||||
}
|
||||
|
@@ -96,6 +96,7 @@
|
||||
<Compile Include="Services\IBlogPostService.cs" />
|
||||
<Compile Include="Services\IBlogService.cs" />
|
||||
<Compile Include="Services\XmlRpcHandler.cs" />
|
||||
<Compile Include="ViewModels\BlogArchivesViewModel.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\Admin\images\draft.gif" />
|
||||
|
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.Blogs.Models;
|
||||
|
||||
namespace Orchard.Blogs.ViewModels {
|
||||
public class BlogArchivesViewModel {
|
||||
public string Slug { get; set; }
|
||||
public IEnumerable<BlogPart> Blogs { get; set; }
|
||||
}
|
||||
}
|
@@ -1,8 +1,17 @@
|
||||
@model Orchard.Blogs.Models.BlogArchivesPart
|
||||
@model Orchard.Blogs.ViewModels.BlogArchivesViewModel
|
||||
|
||||
@using Orchard.Blogs.Models;
|
||||
@using Orchard.Core.Routable.Models;
|
||||
@using Orchard.ContentManagement;
|
||||
|
||||
<fieldset>
|
||||
<div>
|
||||
@Html.LabelFor(m => m.ForBlog, T("For Blog"))
|
||||
@Html.TextBoxFor(m => m.ForBlog)
|
||||
<span class="hint">@T("Show the archives for which blog? Note: specify the blog's slug.")</span>
|
||||
@Html.LabelFor(m => m.Slug, T("For Blog"))
|
||||
<select id="@Html.FieldIdFor(m => m.Slug)" name="@Html.FieldNameFor(m => m.Slug)">
|
||||
@foreach(BlogPart blog in Model.Blogs) {
|
||||
@Html.SelectOption(Model.Slug, blog.As<RoutePart>().Slug, blog.Name)
|
||||
}
|
||||
</select>
|
||||
<span class="hint">@T("Select which blog you want to display the archives for")</span>
|
||||
</div>
|
||||
</fieldset>
|
Reference in New Issue
Block a user