17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2069 Views |
-
Articles(news) in sidebar

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. -
Re: Articles(news) in sidebar

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 "{$Title}"">$Title</a></li>
<% end_control %>
</ul> -
Re: Articles(news) in sidebar

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
| 2069 Views | ||
|
Page:
1
|
Go to Top |


