This project is read-only.

Orchard CMS Recent Blog Post Widget Alternate View

Topics: Customizing Orchard, General
Oct 18, 2013 at 9:34 AM
Edited Oct 18, 2013 at 9:35 AM
I want to display recent blog posts list differently from blog post summaries. I have followed Bertrands post from here :

and have seen discussion on Stack Overflow regarding what I want to achieve here:

but I'm none the wiser. I have probably started this from the wrong way, since I've overwritten to display recent blog posts in desired way:

<Match DisplayType="Summary">
  <Place Parts_Common_Metadata_Summary="Header:1"

while I should probably create alternates for each shape. Was trying to do it, but cannot get it to work. Can you please direct me to any other tutorials explaining this topic? If there are any?
Oct 18, 2013 at 4:05 PM
I did manage to solve this problem. Don't think it's the most elegant solution, but at least it does the job for me. I followed approach from this post:

which I found the most useful of all. I created Parts.Blogs.RecentBlogPosts alternate, and while navigating through the model using shape tracing tool did manage to find all elements I was looking for. Could you please verify if it could be done in any simpler way?
<div class="last-news">
    @foreach (var item in Model.ContentItems.ContentItems.Items)
        var max = (item.ContentItem.BodyPart.Text.Length > 100) ? 100 : item.ContentItem.BodyPart.Text.Length;

        <li><h1><a href="/@item.ContentItem.Parts[5].Path">@Display(item.ContentItem.TitlePart.Title)</a></h1></li>
        <li>@Display(Html.Raw(item.ContentItem.BodyPart.Text.Substring(0, max)))</li>
Mar 20, 2014 at 4:54 PM
Edited Mar 20, 2014 at 4:54 PM
This is perfect, thanks!

var max = (item.ContentItem.BodyPart.Text.Length > 100) ? 100 : 
Obviously means the Text is cut off after 100 characters. How would I add an ellipsis after the 100th character?