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.

Archive

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

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

Articles(news) in sidebar


Reply

3 Posts   2285 Views

Avatar
Anselmo

22 November 2007 at 2:27pm 6 Posts

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

24 November 2007 at 3:53pm Forum Moderator, 5511 Posts

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

26 November 2007 at 2:28pm 6 Posts

Hi willr,

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

Cheers

Anselmo