Jump to:

23003 Posts in 11856 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » unable to show data from database in front end

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

Page: 1
Go to End
Author Topic: 634 Views
  • akshu
    Avatar
    Community Member
    7 Posts

    unable to show data from database in front end Link to this post

    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

  • baba-papa
    Avatar
    Community Member
    279 Posts

    Re: unable to show data from database in front end Link to this post

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

    634 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.