Hello,
I'm currently working on a small news website. So in order to create different news sections, I'm using the Blog module. I set multiple BlogTrees as the main menu items (Politics, Economy, Sports,...), which include multiple BlogHolders. Each Blogholder page has BlogEntries. Now I want to extend the Blog entries to have 3 additional fields in CMS Admin :
DropDownField : categories (report, Interview, Investigation,..) because I want to show the latest Interview in homepage.
Boolean : IsBreaking News
Image : Photo
I followed this doc page http://doc.silverstripe.org/dataobjectdecorator to extend BlogEntry page. So I created the file mysite/code/BlogEntryDecorator.php with the following code in it:
<?php
/* extends BlogEntry page */
class BlogEntryDecorator extends DataObjectDecorator {
function extraStatics() {
return array(
'db' => array(
'Category' => "Enum('Reportage,Raport,Entrevue,Investigation','Reportage')",
'IsBreaking'=>'Boolean',
),
'has_one' => array(
'Photo' => 'Image',
),
);
}
public function updateCMSFields(FieldSet $fields) {
$fields->addFieldToTab('Root.Content.Photo', new ImageField("Image", _t("BlogEntry.IMAGE", "Article Photo")));
$fields->addFieldToTab('Root.Content.Main', new DropdownField("Category", _t("BlogEntry.CATEGORY", "Category"),$this->owner->dbObject('Category')->enumValues()));
$fields->addFieldToTab('Root.Content.Main', new CheckboxField($name = "IsBreaking",$title = _t("BlogEntry.BREAKING", "Breaking News")));
}
}
I also added the following to mysite/_config.php :
Object::add_extension('BlogEntry', 'BlogEntryDecorator');
However, the above code triggers this error for the image only:
[User Error] Uncaught Exception: Object->__call(): the method 'image' does not exist on 'BlogEntry'
So first, is this a correct way to set the structure of such a news site?
if so, what could be the cause of this error?
Thanks in advance..