The problem is the the ImageResouces.php cannot have controller, as long as i delete the controller class, every thing's fine....
though i did change class ImageResource extends DataObject to
class ImageResource extends Image, but I don't think this really matters....
Also, in order to display the image on the page, i cannot use
<% control Images %>
<img src="$Images.URL"/>
<% end_control%>
instead, it should be
<% control Images %>
<img src="$URL"/>
<% end_control%>
it seems doesn't recognize the expression $Images....though I saw a lot of examples online that did use $Images.URL.
Any one can explain a little about this?
Trying to get the image work, not luck now
ImageResource.php
<?php
class ImageResource extends DataObject
{
static $has_one = array (
'SectionPage' => 'SectionPage',
'ImageResource'=>'Image'
);
}
class ImageResource_Controller extends ContentController
{
}
?>
////////////////////////////////////////////////////////
SectionPage.php
class SectionPage extends Page
{
static $has_many= array (
'Images'=>'ImageResource'
);
public function getCMSFields()
{
$fields = parent::getCMSFields();
$manager = new ImageDataObjectManager(
$this,
'Images',
'ImageResource',
'ImageResource',
array('Title'=>'Title', 'Description'=>'Description'),
new FieldSet(
new TextField('Title'),
new TextareaField('Description')
));
$manager -> setAllowedFileTypes(array('jpg', 'png','gif'));
$fields->addFieldToTab("Root.Content.Images", $manager);
return $fields;
}
}
class SectionPage_Controller extends Page_Controller
{
}
?>
Also, the ImagePage.ss i'm not sure what should I put there is this right?
<% control Images%>
$ImageResource
$Title
<% end_control %>