Hi All
I would like to add the last 3 blog post summaries (or first paragraphs?) to a sidebar.
I tried this as a first step:
<% if BlogEntries %>
<% loop BlogEntries %>
<% include BlogSummary %>
<% end_loop %>
<% else %>
<h2><% _t('BlogHolder_ss.NOENTRIES', 'There are no blog entries') %></h2>
<% end_if %>
But it always returns 'There are no blog entires' which I guess indicates BlogEntries isn't populated when the home page loads.
Any ideas where I am going wrong?
SOLVED: This didn't come up in my forum search but reading the post "How to add blog tags to home page" below gave me the answer:
Needed a retrieval function in my page.php file Page_Controller class:
public function LatestBlogs($num=5) {
return DataObject::get('BlogEntry', array('ShowInSearch'=>'1'), 'Date DESC', '', $num);
}
Then in Page.ss
<% if LatestBlogs %>
<% loop LatestBlogs(2) %>
<h3>$MenuTitle</h3>
<p>$Content.Summary()</p>
<% end_loop %>
Seems to work ok.
Cheers