Hi!
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?
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.
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.
HI!
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 "{$Title}"">$Title</a></li>
<li class="newsDateTitle">$Date.Nice</li>
<li class="newsSummary">$Content.FirstParagraph<a href="$Link" title="Read more on "{$Title}"">Read more >></a></li>
<% end_control %>
</ul>
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;
}
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?
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 NeswPage.ss). Everything is blank..