Changed rendering of content items by tag page to look for templates by content type and a template name. Also changed admin link on front end to (temporarily) point to manage blogs page in admin.

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4043360
This commit is contained in:
ErikPorter
2009-12-07 08:34:11 +00:00
parent bcb489fadd
commit 1d9a4d4229
6 changed files with 38 additions and 6 deletions

View File

@@ -103,7 +103,7 @@
<Content Include="Package.txt" /> <Content Include="Package.txt" />
<Content Include="Views\BlogPost\Create.aspx" /> <Content Include="Views\BlogPost\Create.aspx" />
<Content Include="Views\BlogPost\Edit.aspx" /> <Content Include="Views\BlogPost\Edit.aspx" />
<Content Include="Views\BlogPost\EditorTemplates\BlogPostEditViewModel.ascx" /> <Content Include="Views\Models\BlogPost\Summary.ascx" />
<Content Include="Views\Blog\DisplayTemplates\BlogForAdminViewModel.ascx" /> <Content Include="Views\Blog\DisplayTemplates\BlogForAdminViewModel.ascx" />
<Content Include="Views\Blog\ItemForAdmin.aspx" /> <Content Include="Views\Blog\ItemForAdmin.aspx" />
<Content Include="Views\Blog\DisplayTemplates\BlogsForAdminViewModel.ascx" /> <Content Include="Views\Blog\DisplayTemplates\BlogsForAdminViewModel.ascx" />

View File

@@ -0,0 +1,24 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayViewModel>" %>
<%@ Import Namespace="Orchard.Models"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<%@ Import Namespace="Orchard.Models.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
<!-- HACK: (erikpo) Need to figure out how to make the model of the partial be templated -->
<% BlogPost model = Model.Item.As<BlogPost>(); %>
<h3><a href="<%=Url.BlogPost(model.Blog.Slug, model.Slug) %>"><%=Html.Encode(model.Title) %></a></h3>
<div class="meta">
<%=Html.PublishedState(model) %>
| <a href="#">?? comments</a>
</div>
<div class="content"><%=model.Body ?? "<p><em>there's no content for this blog post</em></p>" %></div>
<%--<p class="actions">
<span class="construct">
<a href="<%=Url.BlogPostEdit(model.Blog.Slug, model.Slug) %>" class="ibutton edit" title="Edit Post">Edit Post</a>
<a href="<%=Url.BlogPost(model.Blog.Slug, model.Slug) %>" class="ibutton view" title="View Post">View Post</a><%
if (model.Published == null) { // todo: (heskew) be smart about this and maybe have other contextual actions - including view/preview for view up there ^^ %>
<a href="<%=Url.BlogPost(model.Blog.Slug, model.Slug) %>" class="ibutton publish" title="Publish Post Now">Publish Post Now</a>
<% } %>
</span>
<span class="destruct"><a href="#" class="ibutton remove" title="Remove Post">Remove Post</a></span>
</p>--%>

View File

@@ -4,8 +4,7 @@
<%@ Import Namespace="Orchard.Mvc.Html"%> <%@ Import Namespace="Orchard.Mvc.Html"%>
<%-- todo: (heskew) make master-less when we get into theming --%> <%-- todo: (heskew) make master-less when we get into theming --%>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>List of contents tagged with <%= Model.TagName %></h2><% <h2>List of contents tagged with <%= Model.TagName %></h2>
foreach (var contentItem in Model.Contents) { %> <!-- TODO: (erikpo) The class being used for the lists "posts" should be made into something more generic like "contentItems" for the front end -->
<%=Html.ItemDisplayLink(contentItem)%>&nbsp; <%=Html.UnorderedList(Model.Contents, (c, i) => Html.ItemDisplayTemplate(c, "Summary").ToHtmlString(), "posts")%>
<% } %>
</asp:Content> </asp:Content>

View File

@@ -5,6 +5,6 @@
<li><%= Html.ActionLink("Home", "Index", "Home", new {Area = ""}, new {})%></li> <li><%= Html.ActionLink("Home", "Index", "Home", new {Area = ""}, new {})%></li>
<li><%= Html.ActionLink("About", "About", "Home", new {Area = ""}, new {})%></li> <li><%= Html.ActionLink("About", "About", "Home", new {Area = ""}, new {})%></li>
<li><%= Html.ActionLink("Blogs", "List", "Blog", new {Area = "Orchard.Blogs"}, new {})%></li> <li><%= Html.ActionLink("Blogs", "List", "Blog", new {Area = "Orchard.Blogs"}, new {})%></li>
<li><%= Html.ActionLink("Admin", "Index", new {Area = "Orchard.CMSPages", Controller = "Admin"})%></li> <li><%= Html.ActionLink("Admin", "ListForAdmin", new {Area = "Orchard.Blogs", Controller = "Blog"})%></li>
</ul> </ul>
</div> </div>

View File

@@ -17,6 +17,10 @@ namespace Orchard.Models.ViewModels {
Item = viewModel.Item; Item = viewModel.Item;
} }
public ItemDisplayViewModel(ContentItem item) {
Item = item;
}
public ContentItem Item { public ContentItem Item {
get { return _item; } get { return _item; }
set { SetItem(value); } set { SetItem(value); }

View File

@@ -2,6 +2,7 @@
using System.Web.Mvc; using System.Web.Mvc;
using System.Web.Mvc.Html; using System.Web.Mvc.Html;
using Orchard.Models; using Orchard.Models;
using Orchard.Models.ViewModels;
namespace Orchard.Mvc.Html { namespace Orchard.Mvc.Html {
public static class ContentItemExtensions { public static class ContentItemExtensions {
@@ -42,5 +43,9 @@ namespace Orchard.Mvc.Html {
public static MvcHtmlString ItemEditLink(this HtmlHelper html, IContent content) { public static MvcHtmlString ItemEditLink(this HtmlHelper html, IContent content) {
return ItemEditLink(html, null, content); return ItemEditLink(html, null, content);
} }
public static MvcHtmlString ItemDisplayTemplate(this HtmlHelper html, IContent content, string template) {
return html.Partial(string.Format("{0}/{1}", content.ContentItem.ContentType, template), new ItemDisplayViewModel(content.ContentItem));
}
} }
} }