Providing example of content item display templates

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4043362
This commit is contained in:
loudej
2009-12-07 09:39:09 +00:00
parent 1d9a4d4229
commit 594526e4c6
6 changed files with 42 additions and 4 deletions

View File

@@ -17,6 +17,9 @@ namespace Orchard.Blogs.Models {
Filters.Add(new ActivatingFilter<RoutableAspect>("blogpost"));
Filters.Add(new ActivatingFilter<BodyAspect>("blogpost"));
Filters.Add(new StorageFilter<BlogPostRecord>(repository));
Filters.Add(new ContentItemTemplates<BlogPost>("BlogPost", "Summary"));
OnLoaded<BlogPost>((context, bp) => bp.Blog = contentManager.Get<Blog>(bp.Record.Blog.Id));
OnGetItemMetadata<BlogPost>((context, bp) => {

View File

@@ -110,6 +110,7 @@
<Content Include="Views\Blog\DisplayTemplates\BlogForAdmin.ascx" />
<Content Include="Views\Blog\List.aspx" />
<Content Include="Views\Blog\ListForAdmin.aspx" />
<Content Include="Views\Models\DisplayTemplates\BlogPostSummary.ascx" />
<Content Include="Views\Shared\BlogPostPreview.ascx" />
<Content Include="Views\BlogPost\EditorTemplates\CreateBlogPostViewModel.ascx" />
<Content Include="Views\BlogPost\Item.aspx" />
@@ -140,6 +141,9 @@
<Name>Orchard.Users</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Models\EditorTemplates\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -0,0 +1,22 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemDisplayViewModel<BlogPost>>" %>
<%@ Import Namespace="Orchard.Models"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<%@ Import Namespace="Orchard.Models.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.ViewModels"%>
<h3><a href="<%=Url.BlogPost(Model.Item.Blog.Slug, Model.Item.Slug) %>"><%=Html.Encode(Model.Item.Title)%></a></h3>
<div class="meta">
<%=Html.PublishedState(Model.Item)%>
| <a href="#">?? comments</a>
</div>
<div class="content"><%=Model.Item.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

@@ -100,10 +100,13 @@ namespace Orchard.Tags.Controllers {
public ActionResult Search(string tagName) {
try {
Tag tag = _tagService.GetTagByName(tagName);
IEnumerable<IContent> contents = _tagService.GetTaggedContentItems(tag.Id).ToList();
var contentItems = _tagService.GetTaggedContentItems(tag.Id);
var contentViewModels = contentItems.Select(
item => _contentManager.GetDisplayViewModel(item, null, "Summary"));
var viewModel = new TagsSearchViewModel {
TagName = tag.TagName,
Contents = contents
Items = contentViewModels.ToList(),
};
return View(viewModel);

View File

@@ -6,6 +6,6 @@ using Orchard.Mvc.ViewModels;
namespace Orchard.Tags.ViewModels {
public class TagsSearchViewModel : BaseViewModel {
public string TagName { get; set; }
public IEnumerable<IContent> Contents { get; set; }
public IEnumerable<ItemDisplayViewModel<IContent>> Items { get; set; }
}
}

View File

@@ -6,5 +6,11 @@
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>List of contents tagged with <%= Model.TagName %></h2>
<!-- TODO: (erikpo) The class being used for the lists "posts" should be made into something more generic like "contentItems" for the front end -->
<%=Html.UnorderedList(Model.Contents, (c, i) => Html.ItemDisplayTemplate(c, "Summary").ToHtmlString(), "posts")%>
<%foreach(var item in Model.Items) {%>
<%= Html.DisplayForItem(m=>item) %>
<%}%>
<%--<%=Html.UnorderedList(Model.Items, (c, i) => Html.ItemDisplayTemplate(c, "Summary").ToHtmlString(), "posts")%>--%>
</asp:Content>