Controlling fold in Blog

Topics: General
Mar 7, 2011 at 8:13 PM

Is there a way to control where the fold happens in a blog post or to turn off the fold.  

Coordinator
Mar 7, 2011 at 9:58 PM

Here's the Parts.Common.Body.Summary.cshtml that I put into the Views folder of my theme in order to control that... As you can see, it will split on a more comment (like in WordPress) or on the first paragraph if that's not found. Otherwise, the whole post is used.

@{ 
    Orchard.ContentManagement.ContentItem contentItem = Model.ContentPart.ContentItem;
    var bodyHtml = Model.Html.ToString();
    var more = bodyHtml.IndexOf("<!--more-->");
    if (more != -1) {
        bodyHtml = bodyHtml.Substring(0, more);
    }
    else {
        var firstP = bodyHtml.IndexOf("<p>");
        var firstSlashP = bodyHtml.IndexOf("</p>");
        if (firstP >=0 && firstSlashP > firstP) {
            bodyHtml = bodyHtml.Substring(firstP, firstSlashP + 4 - firstP);
        }
    }
    var body = new HtmlString(bodyHtml); 
}
<p>@body</p>
<p>@Html.ItemDisplayLink(T("Read more...").ToString(), contentItem)</p>
Mar 16, 2011 at 12:46 AM

+1. Thanks Bertrand.