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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

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

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

widget to return last news title

Go to End

5 Posts   1330 Views


Community Member, 87 Posts

10 October 2008 at 3:11am

I look in widget area and I don't find my widget: I need a widget that return my last 4 title of news.
So I have a news pages where I have news title and some breaf description. I want a widget that in homepage return the title of last 5 news. Is this possible? Exist a widget to do thah?


Community Member, 470 Posts

10 October 2008 at 6:18am

This is explained in tutorial 2.

Just modify it to not show links, if you're only interested in the title.

Doubt there is a widget for it, since it is covered here but maybe there is.


Community Member, 87 Posts

15 October 2008 at 2:45am

thanks for your answer but I can't see news.I copy all the code, but something is wrong..

<ul id="NewsList">
<% control LatestNews %>
<li class="newsDateTitle"><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></li>
<li class="newsDateTitle">$Date.Nice</li>
<li class="newsSummary">$Content.FirstParagraph<a href="$Link" title="Read more on &quot;{$Title}&quot;">Read more &gt;&gt;</a></li>
<% end_control %>

I think the problem is link to LatestNews because I can't enter in <% control LatestNews %>.
In function get_one I have "ArticleHolder". this is a link to ArticleHolder.php?My news are in ARticlePage so I don't understand..can you help me?

function LatestNews($num=5) {
$news = DataObject::get_one("ArticleHolder");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;


Community Member, 470 Posts

15 October 2008 at 3:59am

Well you need to change "ArticleHolder" and "ArticlePage" in the LatestNews function to whatever page types you've created. Generally speaking you should have a page that holds all the news (holder page), and then individual news entries. Are these named the same as in the function?

Are you saying no information is returned at all? Everything is blank?


Community Member, 87 Posts

15 October 2008 at 4:55am

Yes, the name of page that memorize article are the same (ArticlePage and ArticleHolder) and the name of new page type where I copy LatestNews is NewsPage.php (and the relative template Everything is blank..