Blog Summaey

Topics: Customizing Orchard
May 24, 2013 at 7:45 PM
How to include First Image and a text summary on the Blog Posts summary page.

Currenlty I use this in the Parts.Common.Body.Summary
@{ 
    Orchard.ContentManagement.ContentItem contentItem = Model.ContentPart.ContentItem;
    string bodyHtml = Model.Html.ToString();
    
    int moreIndex = bodyHtml.IndexOf("<!--more-->");
    if (moreIndex != -1)
    {
        bodyHtml = bodyHtml.Substring(0, moreIndex);
    }
    else 
    {
        int firstP = bodyHtml.IndexOf("<p>");
        int firstSlashP = bodyHtml.IndexOf("</p>");
        if (firstP >=0 && firstSlashP > firstP) 
        {
            bodyHtml = bodyHtml.Substring(firstP, firstSlashP + 4 - firstP);
        }
    }   
    var body = new HtmlString(Html.Excerpt(bodyHtml, 2000).ToString().Replace(Environment.NewLine, "</p>")); 
    //var body = new HtmlString(bodyHtml); 
 }

<p>@body <span class="more">@Html.ItemDisplayLink(T("Continue reading...").ToString(), contentItem)</span></p>
This provides the first image but then no text summary because of the blog post format i.e.:
<p><img width="711" height="209" align="absmiddle" alt="" src="/Media/Default/BlogPost/mr-blog/711x209_1.jpg" /></p>
<p>Windows 8 is a version of Microsoft Windows (an operating system developed by Microsoft) for use on personal computers, including home and business desktops, laptops, tablets, and home theater PCs. Development of Windows 8 started before the release of its predecessor, Windows 7, in 2009. Its existence was first announced at CES 2011, and followed by the release of three pre-release versions from September 2011 to May 2012. The operating system was released to manufacturing on August 1, 2012, and was released for general availability on October 26, 2012.[3] Windows 8 uses version 6.2 of the Windows NT kernel.</p>
Between the first <p> is only the image.

Any ideas in include the first 2 x <p> tags
May 26, 2013 at 12:03 AM
Answered myself as a work around ensure when posting the image use a break tag instead of a slash p, this pushes the text under the picture and shows image and summary on the post blog summary page.

Solved Indirectly