Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Orchard Blog Summary Text

On the blog summary page -the one that lists your blog posts- I could do with having a bit more of the text visible from each blog post.

Is this possible? I cant see it anywhere in the settings and for some reason shape tracing isnt letting me see what the template is for this.

like image 360
Phill Healey Avatar asked Mar 05 '13 16:03

Phill Healey


2 Answers

I needed to do the same thing recently on Orchard v1.6. You're using the shape tracing so you're going in the right direction. The orchard documentation for alternates and placement cover this. There's a good example of this kind of modification on Tony Johnson's Argument Exception Blog.

As per Phil's answer, you need to modify the placement.info in your current theme to use an alternate view like so;

<Match ContentType="BlogPost">
<Match DisplayType="Summary">
    <Place Parts_Common_Body_Summary="Content:5;Alternate=Parts_BlogPostSummaryBody"/>
</Match>
</Match>

And then add an alternate part named "Content-BlogPost.Summary.cshtml" in your theme's view folder;

@using Orchard.ContentManagement.ViewModels
@using Orchard.ContentManagement
@using Orchard.Core.Common.Models

@{      
ContentItem item = Model.ContentItem;
string title = Model.Title.ToString();
BodyPart bpItem = item.As<BodyPart>();
string linkUrl = Url.ItemDisplayUrl(item);
}

<h4>@Html.ItemDisplayLink(title, item)</h4>
<div class="publishinfo">@Model.ContentItem.CommonPart.PublishedUtc by @Model.ContentItem.CommonPart.Owner.UserName</div>
      <div>
   <p>@Html.Raw(@bpItem.Text)</p>
</div>
like image 95
Tristan Avatar answered Oct 05 '22 17:10

Tristan


Through reading other post I found that the view responsible for this was Parts_Common_Body_Summary. So I copied this from the core / common folder of orchard and copied it across to my themes view folder, before renaming it to Parts_Blog_Summary

I then set-up a rule for this in Placement.info as follows:

<Match ContentType="BlogPost">
<Match DisplayType="Summary">
        <Place Parts_Common_Body_Summary="Content:after;Alternate=Parts_Blog_Summary"/>
</Match>    
</Match>

This just left me the task of altering the string length in the new alternate view:

var body = new HtmlString(Html.Excerpt(bodyHtml, 350).ToString().Replace(Environment.NewLine, "</p>" + Environment.NewLine + "<p>"));
like image 41
Phill Healey Avatar answered Oct 05 '22 17:10

Phill Healey