Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Problem trying to show ArticlePages in HomePage

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

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

Page: 1
Go to End
Author Topic: 899 Views
  • denki
    Avatar
    Community Member
    1 Post

    Problem trying to show ArticlePages in HomePage Link to this post

    Hi, I'm new to silverstripe. I need to finish a small setup for tomorrow and I'm having problems showing the ArticlePages in the homepage . I'm following the article :
    http://doc.silverstripe.com/doku.php?id=tutorial:2-extending-a-basic-site
    exactly like it's there.
    I checked and the site is reading my HomePage.php from code HomePage.ss and the and Article related pages (I can create them and see them in the Article (News) section).
    I also tried just echoing a value from the HomePage.php but still blank.
    The code follows:

    HomePage.ss
    //
    <% 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 %>
    //

    HomePage.php
    //
    class HomePage_Controller extends Page_Controller {

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

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Problem trying to show ArticlePages in HomePage Link to this post

    does the php error log contain anything useful?

    Otherwise I would just strip the PHP down to see what its failing by removing things like the ParentID= bit then the sort or try just a return DataObject::get("ArticlePage");

    899 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.