Hello SilverStripe folks,
I've got a newsarticle.php page and a newsarticleholder.php.
This is my NewsArticle.php
<?php
class NewsArticle extends DataObjectAsPage {
//The class of the page which will list this DataObject
static $listing_class = 'NewsArticleHolder';
//Class Naming (optional but reccomended)
static $plural_name = 'NewsArticles';
static $singular_name = 'NewsArticle';
static $db = array (
'Title' => 'Varchar(255)',
'Date' => 'Date',
'Author' => 'Text',
'Content' => 'HTMLText',
);
static $has_one = array (
'NewsHolder' => 'NewsArticleHolder',
);
//Summar fields
static $summary_fields = array(
'Title',
'Date',
'Author',
'Content'
);
function fieldLabels($includerelations = true) {
$labels = parent::fieldLabels($includerelations);
$labels['Title'] = _t('newsarticle.TITLE', 'Titel');
$labels['Date'] = _t('newsarticle.DATE', 'Datum');
$labels['Author'] = _t('newsarticle.AUTHOR', 'Auteur');
$labels['Content'] = _t('newsarticle.CONTENT', 'Niewsbericht');
return $labels;
}
function getCMSFields() {
$fields = new Fieldset();
$fields->push(new TextField('Title','Titel'), 'Content');
$fields->push($dateField = new DateField('Date','Datum'), 'Content');
$dateField->setConfig('showcalendar', true);
$dateField->setConfig('dateformat', 'dd/MM/YYYY');
$fields->push(new TextField('Author','Auteur'), 'Content');
$fields->push(new HtmlEditorField("Content", _t('SiteTree.FOO', "Content", PR_MEDIUM, 'HTML editor title')));
return $fields;
}
}
and this is my NewsArticleHolder.php
<?php
class NewsArticleHolder extends DataObjectAsPageHolder {
static $has_many = array (
'NewsArticles' => 'NewsArticle',
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldsToTab("Root.Content.Nieuws", new DataObjectManager($this, 'NewsArticles', 'NewsArticle'));
return $fields;
}
}
class NewsArticleHolder_Controller extends DataObjectAsPageHolder_Controller {
//This needs to know be the Class of the DataObject you want this page to list
static $item_class = 'NewsArticle';
//Set the sort for the items (defaults to Created DESC)
static $item_sort = 'Title ASC';
}
?>
So my CMS just works fine, can add newsitems but when im on the newspage,
it wont show my newsitems :(
This is my NewsArticleHolder.ss
<div class="typography">
<% if Level(2) %>
<div class="breadcrumbs">
$Breadcrumbs
</div>
<% end_if %>
<h2>$Title</h2>
<div>
$Content
</div>
<div class="articles">
<ul id="NewsList">
<% control NewsArticles %>
foo
$Title
<% end_control %>
</ul>
</div>
$Form
$PageComments
</div>
Please help me guys!! I have no idea what i'm doing wrong, and im quite new to this....
Thanks!!