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.

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.

Customising the CMS /

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

CMS shows blank on edit page


Go to End


2 Posts   1252 Views

Avatar
AD5XJ

Community Member, 35 Posts

17 March 2017 at 8:05am

I am attempting to make a custom news holder and article page per the docs here: https://docs.silverstripe.org/en/4/tutorials/extending_a_basic_site/

The news holder works fine but when attempting to edit the article page it only displays blank. It creates a default page but I cannot edit it.

This is the code in my NewsArticlePage.php:

<?php

class NewsArticlePage extends Page {
    private static $db = array(
        'PubDate' => 'Date', 
        'Author' => 'Text'
         );

    public function getCMSFields() {
        $fields = parent::getCMSFields();

        $dateField = new DateField('PubDate', 'Article Date');
        $dateField->setConfig('showcalendar', true);
        $dateField->setConfig('dateformat', 'YYYY-MM-dd');

        $fields->addFieldToTab('Root.Main', $dateField, 'Content');
        $fields->addFieldToTab('Root.Main', new TextField('Author', 'Author Name'), 'Content');

        return $fields;
   }
}

class NewsArticlePage_Controller extends Page_Controller {

}

mysite/simple/NewsArticlePage.ss

<% include SideBar %>
<div class="content-container unit size3of4 lastUnit">
 <article>
  <h1>$Title</h1>
  <div class="news-details"><p>Posted on $Date.Nice by $Author</p></div>
  <div class="content">$Content</div>
 </article>
 $Form
</div>

Before anyone asks...Yes - I did do the obligatory dev/build and flush.

Avatar
AD5XJ

Community Member, 35 Posts

17 March 2017 at 11:55am

SOLVED!

I have descovered that the date format 'YYYY-MM-dd' breaks the code. When using 'MM/dd/YYYY' it works correctly.

Looks like a rookie mistake on my part.