Jump to:

10845 Posts in 2513 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » News Article: Date not showing on live site

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 702 Views
  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: News Article: Date not showing on live site Link to this post

    Hmmm, I don't see anything out of the ordinary - if Date is the actual fieldname defined in the NewsArticle (?) class.

    The only thing I can think of now is that that fieldname (Date) might somehow conflict with something. What if you'd name it, say, DatePosted? I realize it's a long shot, but I remember seeing something like this before...

  • IDOLYZ
    Avatar
    Community Member
    40 Posts

    Re: News Article: Date not showing on live site Link to this post

    Tried that too (i renamed it to ArticleDate) and it didn't work

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: News Article: Date not showing on live site Link to this post

    OK, so:

    - you made sure the Date field on the productionsite in the DB actually had a date in it
    - you did dev/build?flush=1 after changing the fieldname Date to ArticleDate
    - you made sure the new ArticleDate field in the DB actually had a date in it
    - you did ?flush=1 after every template change
    - the date actually is visible in the CMS field for the page

    Then there really isn't much else I can think of from here Wonder what this does:

    public function LatestNews($num=5) {
       $holder = ArticleHolder::get()->First();
       $pages = ($holder) ? ArticlePage::get()->filter('ParentID', $holder->ID)->sort('Date DESC')->limit($num) : false;

       if ($pages) foreach ($pages as $page) echo "*** {$page->Title}, {$page->Date} ***<br>";

       return $pages;
    }

  • IDOLYZ
    Avatar
    Community Member
    40 Posts

    Re: News Article: Date not showing on live site Link to this post

    Hi,

    Sorry for late reply. Have been on holidays...

    I used that code and the date shows correctly:

    *** Chronically tight muscles stop sending pain signals, 2013-10-02 ***
    *** Massage this Long Weekend?, 2013-09-24 ***
    *** Pathology Testing, 2013-09-11 ***

    How do I now get $page->Date to display on the page and RSS feed? Have tried $Date and $Date.Nice but doesn't work.

    Thanks

    702 Views
Page: 1 2
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.