Jump to:

1851 Posts in 1606 Topics by 561 members

Blog Module

SilverStripe Forums » Blog Module » How display all blog tags on home page

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 1268 Views
  • neografik
    Community Member
    7 Posts

    How display all blog tags on home page Link to this post

    Hello everyone!

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

  • inCharge
    Community Member
    102 Posts

    Re: How display all blog tags on home page Link to this post

    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.

    In homepage.ss...

                <% 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');

  • PaulO2
    Community Member
    2 Posts

    Re: How display all blog tags on home page Link to this post

    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);

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.