7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » ImageDataObjectManager i can't get this to work...
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | ||
| Author | Topic: | 1651 Views |
-
Re: ImageDataObjectManager i can't get this to work...

19 October 2009 at 6:18am
ok I have checked the names and now have.
Imagetest.php
<?php
class Imagetest extends DataObject
{
static $db = array (
'Name' => 'Text',
'Description' => 'Text',
'Category' => "Enum('Industry, Finance, Education')"
);
static $has_one = array (
'ImagetestPage' => 'ImagetestPage',
'Attachment' => 'Image'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name'),
new TextareaField('Description'),
new DropdownField('Category','Category', singleton('Imagetest')->dbObject('Category')->enumValues()),
new FileIFrameField('Attachment')
);
}
}?>
ImagetestPage.php
<?php
class ImagetestPage extends Page
{
static $has_many = array (
'Imagetests' => 'Imagetest'
);
public function getCMSFields()
{
$f = parent::getCMSFields();
$imagemanager = new ImageDataObjectManager(
$this, // Controller
'Imagetests', // Source name
'Imagetest', // Source class
'Attachment', // File name on DataObject
array(
'Name' => 'Name',
'Description' => 'Description',
'Category' => 'Category'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$f->addFieldToTab("Root.Content.Imagetests",$imagemanager);
return $f;
}}
class ImagetestPage_Controller extends Page_Controller {
}
?>
and
ImagetestPage.ss
<% if Menu(2) %>
<ul id="Menu2">
<% control Menu(2) %>
<li class="$LinkingMode"><a href="$Link" title="Go to the $Title page">$MenuTitle</a></li>
<% end_control %>
</ul>
<% end_if %><div id="Content" class="typography">
<% if Level(2) %>
<div class="breadcrumbs">
$Breadcrumbs
</div>
<% end_if %>
<h1>$Title</h1><% control Imagetests %>
$Description
<% end_control %>$Content
</div>
I dropped the imagetet table and rebuilt database.
Now when I click on Imagetest page in CMS it does not load at all?
why would this work for filedataobjectmanager and not image one?
Is there anytutorial on specifically the imagedataobjectmanager?
-
Re: ImageDataObjectManager i can't get this to work...

19 October 2009 at 8:48am
Hey unclecheese... you'll be glad to hear I got this working... i had to start new silverstripe installation. and just went and did imagedataobjectmanager page instead of file...
So I think I must have gor things confused with classes and tables etc..
I can now loop through the images. using the below
<% control Resources %>
<% control Attachment %>
$CroppedImage(100,100)
<% end_control %>
<% end_control %>and it is producing all my images to page.
Can I ask how do i access say number one or two individually? and just produce that to page... or if foe example I call one of my images 'logo' can i access just that in a particular place.
| 1651 Views | ||
| Go to Top |

