Can I make Orchard show the entirety of a blog post in the blog list?
Asked Answered
S

2

10

I just set up Orchard and noticed that the preview widget only shows the first couple sentences with the standard "more" link. Is there a way to override this functionality without creating a custom widget? I would like Orchard to show the entirety of my latest five posts.

Sacerdotal answered 20/2, 2011 at 10:38 Comment(0)
P
9

Sure, just put this Parts.Common.Body.Summary.cshtml in the views directory of your theme:

@{
    Orchard.ContentManagement.ContentItem contentItem = Model.ContentPart.ContentItem;
    var bodyHtml = new HtmlString(Model.Html.ToString());
}

<p>@bodyHtml</p>
Psychologism answered 20/2, 2011 at 23:58 Comment(4)
Thanks a ton. That was easy and awesome. I need to read more documentation, but I am just starting out with Orchard.Sacerdotal
Thanks a lot. This worked for me, thought I had to edit in Core\Views since my theme didn't override it. I haven't found a better solution yet. I'm surprised this isn't an option in the configuration yet. It feels like it should be.Ruthieruthless
@bertrand le roy: how can I put comments in blog list? I mean how to show comments bellow each postRoam
Please ask new questions as new questions.Psychologism
E
9

I wanted to do something similar without overriding the Common.Body.Summary part for the whole site. I only wanted BlogPosts to use the full HTML for the Summary. I think I've accomplished this by adding the following line to Placement.info:

<Match ContentType="BlogPost">
    <Match DisplayType="Summary">
        <Place Parts_Common_Body_Summary="Content:after;Alternate=Parts_Common_Body"/>
    </Match>
</Match>
Endermic answered 14/4, 2012 at 19:8 Comment(1)
By adding the atrribute Path="/blog" to the Match element, I was able to show the full text of the post on the Blog page, while keeping short summaries in the home page widget.Weidar

© 2022 - 2024 — McMap. All rights reserved.