Custom View For RecentBlogPosts in Orchard

孤街浪徒 提交于 2019-12-06 05:16:00

The ContentItem is a BlogPost content item, which contains BlogPostPart (from Orchard.Blogs.Models namespace). So you can use any properties it has - checkout the link to the source code I provided above.

This part has the Text property, which returns the Html from corresponding BodyPart (which BlogPost type has attached too) under the hood. And btw - Remember to use @Html.Raw(part.Text) to display the fetched content.

One more thing - for making life easier I'd rather cast that iterated objects to BlogPostPart to get Intellisense:

@foreach (var post in blogPosts.Select(p => ((IContent)p.ContentItem).As<BlogPostPart>())) 
{ 
    ... 
}

HTH

You might want to try the shape tracing feature in Orchard 1.1 (due next week). The model tab in there will enable you to dig into the objects and figure out the syntax to display pretty much anything.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!