I want a simple widget for my right side column that can display a list of recent blog posts.
is there an easy way to do this other than creating my own widget? i've searched the gallery for one and wasn't able to find one.
can someone point me in the right direction?
EDIT: [SOLUTION]
First I added the Recent Blog Posts widget. Then I created a file Parts.Blogs.recentBlogPosts.cshtml and placed it under the Views directory of my theme. Here's the contents of the file (taken from here: http://weblogs.asp.net/bleroy/archive/2011/03/27/taking-over-list-rendering-in-orchard.aspx)
@using Orchard.ContentManagement;
@{
IEnumerable<object> blogPosts =
Model.ContentItems.ContentItems;
}
@if (blogPosts == null || blogPosts.Count() < 1) {
<p>@T("No posts.")</p>
}
else {
<ul class="content-items">
@foreach (dynamic post in blogPosts) {
string title = post.Title;
开发者_StackOverflow ContentItem item = post.ContentItem;
<li class="content-item-summary">
@Html.ItemDisplayLink(title, item)
</li>
}
</ul>
}
I'm looking at Orchard 1.2 and there is a 'Recent Blog Posts Widget' available to you - all you need to do is add it to your preferred layer/zone.
Other than coding your own view, there are two other ways to customize what is shown.
- Placement.info file. you can tell it what fields to show for a given contentType and/or DisplayType (summary or detail.) You can also tell it what order to display the fields.
From the sample file in the thememachine theme.
<Match ContentType="Blog">
<Match DisplayType="Summary">
<Place Parts_Blogs_Blog_Description="Content:before"
Parts_Blogs_Blog_BlogPostCount="Meta:3"/>
</Match>
</Match>
- A quick hack is to use CSS to hide the content you don't want. I used this for blogPost metadata before I discovered the placement.info
BTW - I don't know if your familiar with the designer tools module, but it's invaluable!
精彩评论