I'm trying to render the list of blog posts in this layout:
[first post - special summary]
[second post][third post][fourth post]
[pager]
I'm trying to render the first post myself and then loop over the remaining items to render them using the blog post summary template.
A number of questions here:
- Is this a good way to pull off the layout I'm trying to achieve or should I start looking into creating a module?
- Should I create a summary template for my special first post rendering and how would I go about that?
- If I continue down the same path how do I render parts like tags and the postdate?
I have this so far in my theme: Parts.Blogs.BlogPost.List-url-blog.cshtml
@using Orchard.Blogs.Extensions;
@using Orchard.Blogs.Models;
@using Orchard.ContentManagement;
@using Orchard.Utility.Extensions;
@{
IEnumerable<dynamic> blogPosts = Model.ContentItems;
Model.ContentItems.Classes.Add("content-items");
Model.ContentItems.Classes.Add("blog-posts");
var firstPost = blogPosts.FirstOrDefault();
//BlogPart blog = (BlogPart)firstPost.Get(typeof(BlogPart));
}
<h1>@firstPost.Title</h1>
by <span>@firstPost.ContentItem.CommonPart.Owner.NormalizedUserName</span>
@* How do i render tags using the tags part template? *@
@Display(firstPost.Tags)
@Display(firstPost.Parts_Tags_ShowTags)
@Display(firstPost.TagsPart)
@Display(firstPost.ContentItem.TagsPart)
@Display(firstPost.ContentItem.TagsPart.ContentItem)
@* none of the above work *@
<hr />
<ul class="content-items">
@foreach (var post in blogPosts.Skip(1))
{
<li class="content-item-summary">
@Display(post)
</li>
}
</ul>
Bonus points - Why can't I do something like this:
@Display(blogPosts.Skip(1))
but I can do
@Display(blogPosts)