7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Preview: DataObjectManager module
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 | Next > | |
| Author | Topic: | 54215 Views |
-
Re: Preview: DataObjectManager module

19 March 2009 at 10:36am Last edited: 19 March 2009 10:37am
No, it's not the only class that uses FileDataObjectManager. I'll try setParentClass().
Here's PDFResource:
class PDFResource extends DataObject
{
static $db = array (
'Name' => 'Varchar(30)'
);
static $has_one = array (
'Thumbnail' => 'Image',
'PDF' => 'PDF', // this class is an extension of File which adds the ability to generate a thumbnail of the PDF's first page.
'Page' => 'Page'
);
} -
Re: Preview: DataObjectManager module

19 March 2009 at 10:52am
Yeah, you need to because $has_one Page is too ambiguous. It's going to try to set QualityPDFPageID on your object, which is a field that doesn't exist, so you wont' get the relation. Make sure you set your FileDataObjectManager object to ->setParentClass("Page")
-
Re: Preview: DataObjectManager module

19 March 2009 at 11:10pm
Hi Uncle Cheese,
Checked out the latest today and noticed a few issues. Looks like revision 82 has caused a couple of issues with DataObjectManager.php. On line 288 I changed from:
$dropdown = new DropdownField('Filter',$this->filter_label . " (<a href='#' class='refresh'>'._t('DataObjectManager.REFRESH','refresh').'</a>)", $map, $value);
to:
$dropdown = new DropdownField('Filter',$this->filter_label . " (<a href='#' class='refresh'> "._t('DataObjectManager.REFRESH','refresh')."</a>)", $map, $value);
Also, the removal of...
protected $view = "list";
and the public function ListStyle() causes the DataObjectManager Tab layout and the Albums Tab layout on an ImageGalleryPage to break.
David
-
Re: Preview: DataObjectManager module

20 March 2009 at 3:57am Last edited: 20 March 2009 3:58am
Uncle Cheese,
Thanks for the help. Still no go. With --
-- no files show up in the file data object manager. Of note, PageID in the database table pdfresource is being set to zero. I'm guessing that if we figured out how to get field PageID to be set to the correct value, things might work. Any ideas?$manager->setParentClass('Page');
Revised code below.
Thank you,
Ben
--------------Revised Code:
class QualityPDFPage extends QualityChildPage {
static $has_many = array(
'PDFResource' => 'PDFResource'
);
static $db = array();
static $can_be_root = false;
static $allowed_children = array();function getCMSFields() {
$fields = parent::getCMSFields();$manager = new FileDataObjectManager(
$this, // Controller
'PDFResource', // Source name
'PDFResource', // Source class
'PDF',
array(
'Name' => 'Name'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object));
$manager->setParentClass('Page');
$fields->addFieldToTab('Root.Content.Resources', $manager);
$fields->removeFieldFromTab("Root.Content.Main", "Content");
return $fields;
}
}class PDFResource extends DataObject
{
static $db = array (
'Name' => 'Varchar(30)'
);
static $has_one = array (
'PDF' => 'PDF',
'Page' => 'Page'
);
} -
Re: Preview: DataObjectManager module

20 March 2009 at 4:00am
I'm not sure why UncleCheese proposed to set the parent class to Page, but did you try to setParentClass('QualityPDFPage')?
-
Re: Preview: DataObjectManager module

20 March 2009 at 4:12am
Good thought, ntessore. I don't think it will work, though, as there is no QualityPDFPageID column in the PDFResource table.
-
Re: Preview: DataObjectManager module

20 March 2009 at 4:28am
bgribaudo, in my code and all the examples i have seen it is required to have a reference to your page type from the resource object. Are you sure you shouldn't have something like
class QualityPDF extends PDFResource
{
static $has_one = array (
'Page' => 'QualityPDFPage '
);
}
and then you could setParentClass('QualityPDFPage')Good Luck, I'm no expert.
-
Re: Preview: DataObjectManager module

20 March 2009 at 7:19am Last edited: 20 March 2009 7:20am
Yeah, the parent class has to be the one that's in your has_one relationship. Put it this way.. setParentClass() tells the table which ID field it will update. so setParentClass('Page') means it will try to update PageID on the object. setParentClass('QualityPDFPage') will try to update the field QualityPDFPageID.
@David -- Thanks for these fixes. I've checked them in.
| 54215 Views | ||
| Go to Top | Next > |


