Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Articles(news) in sidebar

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 2273 Views
  • Anselmo
    6 Posts

    Articles(news) in sidebar Link to this post


    First of all I'm loving this cms, the creators have done a very good job in ss.

    I would like to know if it is possible to have articles in the homepage in a two columns layout. For example have the latest 3 articles in a right column and the $Content in the left column.

    It is possible to achieve this?
    Thanks for your help.

  • Willr
    Forum Moderator
    5508 Posts

    Re: Articles(news) in sidebar Link to this post

    This is pretty simple to do. This is covered in the 2nd tutorial so you might want to read that http://doc.silverstripe.com/doku.php?id=tutorial:2-extending-a-basic-site . Basically you need to do 2 things. I am going to assume you have your holder/news page types the same as Tutorial 2.

    So step 1 Make the function that gets the latest news. Add this to the class Page_controller in Page.php.

    function LatestNews() {
    $news = DataObject::get("ArticlePage", "", "Date DESC", "", 3) ;
    return ($news) ? $news : false;

    One that you have that function you need to output the news list on the website. So you need to add some code like this to where ever you want to out put the latest news -

    <ul id="NewsList">
    <% control LatestNews %>
    <li><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></li>
    <% end_control %>

  • Anselmo
    6 Posts

    Re: Articles(news) in sidebar Link to this post

    Hi willr,

    Thanks, it works like a charm. I should have read the tutorials whith more attention.



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.