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

How display all blog tags on home page


3 Posts   1396 Views


10 January 2012 at 8:08am Community Member, 7 Posts

Hello everyone!

I can't find out on forum, how display all blog tags on home page? Any ideas?


28 March 2012 at 12:25am Community Member, 102 Posts

In HomePage.php...

   function LatestBlogs() {
      return DataObject::get('BlogEntry', 'ShowInSearch=1', 'Date DESC', '', 5);

This shows the most recent 5 posts, from newest to oldest. Change the last parameter to change the number of posts returned.
Posts with 'Show In Search' unchecked are excluded.


            <% control LatestBlogs %>
            <li class="$LinkingMode<% if first %> first<% else_if last %> last<% end_if %>"><a href="$Link">$MenuTitle</a></li>
            <% end_control %>

The classes first & last are added to help with styleing.

Optionally, if you plan on having a lot of blog posts, add a database index to the blog date field to speed up the LatestBlogs function. Add BlogEntryDecorator.php

class BlogEntryDecorator extends DataObjectDecorator {
   public function extraStatics() {
      return array(
         'indexes' => array(
            'date' => '(Date)',

Add to _config.php

Object::add_extension('BlogEntry', 'BlogEntryDecorator');


23 January 2014 at 2:22am (Last edited: 28 January 2014 7:38pm), Community Member, 2 Posts

Is there a Blog Module User Guide somewhere which describes how to do this in SS3? After some trial and random bits of information from widely distributed sources, I found that I needed to change the "control" to "loop" and then I could display $MenuTitle and $Content.Summary() with classes and formatting of my choosing.

My retrieval function in my _Controller is:

public function LatestBlogs($num=5) {
return DataObject::get('BlogEntry', array('ShowInSearch'=>'1'), 'Date DESC', '', $num);