Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Q: Multiple blogs with latest post on HomePage

Go to End

17 Posts   5724 Views


4 May 2009 at 9:19pm Community Member, 54 Posts

I'll use blog module for news site. Since we don't have categories like in forum module. I had to create a Blog Holder for each section.

Now, i would like to display from each section latest blog posts on Home Page.

|- blog holder 1 (section 1 of news)
|- blog holder 2 (section 2 of news)
|- blog holder n (section n of news)

Applying or i'll get only entries from [blog holder 1].

Any idea to do this ?



11 May 2009 at 1:00am Community Member, 395 Posts

this gave me the idea to create a widget to make this possible, I will start on it soon! would be nice to have such a thing ;)


7 June 2009 at 4:12pm Community Member, 395 Posts

As i wrote about a widget, I create a new widget to achieve this. Welcome to use it.

Attached Files
Web Designer Perth

12 June 2009 at 6:52pm Community Member, 49 Posts

@Nivanka - I DL'd your widget. Works perfectly.

I used the blog module as just part of a bigger site - how can I get the latest post on the main 'static' homepage?

Any help much appreciated as I'm a complete noob.

Web Designer Perth

15 June 2009 at 11:21am Community Member, 49 Posts

I would also like to know if there is a way, when showing multiple latest entries in the widget, to have the newest entry at the top of the list; oldest at the bottom. Currently it's the other way round and I can't seem to find any code governing the order.


17 June 2009 at 7:54am (Last edited: 17 June 2009 7:55am), Community Member, 41 Posts

For managing latest post of more blog holders you have to create for each holder a function like describe and extend it:

$news = DataObject::get_one('BlogHolder', "Title = '<name of blogholder>'")


Web Designer Perth

3 July 2009 at 1:16pm (Last edited: 5 July 2009 4:02pm), Community Member, 49 Posts

Ok, I figured out how to swap the order of entries in the widget (newest top, oldest bottom), but despite setting it to show the 6 latest entries in the cms, all entries appear in the widget ie. more than 6.

Can anyone assist?

Here is the code:


// LatestBlogPost Widget 0.0.1 for the SilverStripe Blog Module
// 07.06.2009
// By
// Save this and to widget_latestblogpost/ and run "db/build".

class LatestBlogPost extends Widget{

   static $title = "Latest News";
   static $cmsTitle = "Latest News";
   static $description = "With this plugin you can show up the latest blog post from any blog set up on your website.";

   static $db = array(
      "Blog" => "Int",
      "NumberOfPosts" => "Int",

   //get the wanted data from the user
   function getCMSFields(){
      $blogs = DataObject::get('BlogHolder');
      $blogsDD = array();
      foreach($blogs as $blog)      
         $blogsDD[$blog->ID] = $blog->Title;

      return new FieldSet(
         new DropdownField("Blog", "Select a Blog", $blogsDD, $this->Blog ),
         new NumericField("NumberOfPosts", "Number of Posts")   


   //get the blog posts as the parameters provided
   function blogPosts(){
      $posts = DataObject::get('BlogEntry', 'ParentID = ' . $this->Blog, 'Date DESC', $this->numberOfPosts);
      return $posts;




5 July 2009 at 9:58pm Community Member, 395 Posts

so do you want to show all the posts?

if so, edit the code like this

//get the blog posts as the parameters provided
function blogPosts(){
$posts = DataObject::get('BlogEntry', 'ParentID = ' . $this->Blog, 'Date DESC');
return $posts;

Go to Top