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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

Articles(news) in sidebar


Go to End


3 Posts   2917 Views

Avatar
Anselmo

6 Posts

22 November 2007 at 2:27pm

Hi,

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.

Avatar
Willr

Forum Moderator, 5523 Posts

24 November 2007 at 3:53pm

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 %>
</ul>

Avatar
Anselmo

6 Posts

26 November 2007 at 2:28pm

Hi willr,

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

Cheers

Anselmo