Making ‘News’ Page with Addons in SilverStripe CMS Part 3

Next we learn about how to show max 5 news on homepage and also how to allow comments on ArticlePage

  1. For adding the Latest news to HomePage.php:
    //this must be inside HomePage_Controller area
    function LatestNews($num=5) {
        $news = DataObject::get_one("ArticleHolder");
        return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
    }
  2. and in your theme Homepage.ss use:
    <ul id="NewsList">
        <% control LatestNews %>
            <li class="newsDateTitle"><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></li>
            <li class="newsDateTitle">$Date.Nice</li>
            <li class="newsSummary">$Content.FirstParagraph<a href="$Link" title="Read more on &quot;{$Title}&quot;">Read more &gt;&gt;</a></li>
        <% end_control %>
    </ul>
  3. For allowing commenting in ArticlePage use in ArticlePage.ss following code after all the other content stuff like gallery, content text this code:
    $PageComments

    Also be sure that in behaviour tab the allow comments on this page is checked

4.  Rebuild database using www.yoursitename.com/dev/build?flush=1

Looking for quality SilverStripe Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , , , , | Posted under SilverStripe CMS | RSS 2.0

Author Spotlight

Teet Bergmann

Teet Bergmann

I'm a freelance web designer from Estonia. Mostly doing sites using Silverstripe, magento, prestashop, wordpress.

Leave a Reply

Your email address will not be published. Required fields are marked *


− 7 = 2

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>