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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

unable to show data from database in front end


Reply


2 Posts   702 Views

Avatar
akshu

Community Member, 7 Posts

3 April 2010 at 11:32pm

i have included this code in my ArticlePage as

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

and

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

in ArticlePage.ss but in front end article page it is not showing the news detail

please help

Avatar
baba-papa

Community Member, 279 Posts

5 April 2010 at 4:48am

The method DataObject::get_one() returns only one DataObject.
I would try to get out what the controller method really returns with Debug:log()