Jump to:

23371 Posts in 18161 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » Recent Posts Sidebar

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1596 Views
  • SSTN
    Avatar
    Community Member
    9 Posts

    Recent Posts Sidebar Link to this post

    Hi, I'm building my first site with ss. WooHoo!
    I'm trying to figure out how I can insert a sidebar that displays the most recent blog posts.
    I'll be doing this on the homepage only.

    Thanks in advance!

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: Recent Posts Sidebar Link to this post

    hmmz
    how many pages u wanna show in recent pages module?
    what pagetype u use for the pages??

    I have used the latestnews module functionality

  • Willr
    Avatar
    Forum Moderator
    5489 Posts
  • SSTN
    Avatar
    Community Member
    9 Posts

    Re: Recent Posts Sidebar Link to this post

    Willr, Thanks.
    Does this apply to the Blog Module? That's what I'm using.
    I'm not a coder, so I just get by, and I can't figure this out.

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Recent Posts Sidebar Link to this post

    It can be applied to anything. If you want to show the latest Blog Entries these are under the classname 'BlogEntry' so simply adapt that function to

    function LatestNews($num=5) {
    return DataObject::get("BlogEntry", "Date DESC", "", $num);
    }

    Then in the template you can use <% control LatestNews %>$Title, $Content...<% end_control %>.

    Thats how to build it using custom controls. If you have a sidebar already filled with widgets you could use a widget like http://silverstripe.org/blog-links-widget/

  • SSTN
    Avatar
    Community Member
    9 Posts

    Re: Recent Posts Sidebar Link to this post

    Aha! Nevermind. The instructions in the tutorial worked fine. I was just misunderstanding how to properly flush the cache to see the change.
    Thanks!

    1596 Views
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.