7912 Posts in 1355 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: | 54239 Views |
-
Re: Preview: DataObjectManager module

24 March 2009 at 6:45pm
Hi, dataobject_manager is working out great for a current site, but I need to have images resized on upload (2 sizes: thumbnail and larger). I've read through the general GD and upload stuff but can't get my head around where the functions would sit....I've got this in TreeImage.php (TreeImages are pictures of trees:)
class TreeImage extends DataObject
{
static $db = array (
'TreeImageCaption' => 'Text',
);
static $has_one = array (
'TreeImageFile' => 'Image',
'TreePage' => 'TreePage'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('TreeImageCaption'),
new ImageField('TreeImageFile')
);
}
}so, I want to do something like:
function generateTreeThumb($gd) {
$gd->setQuality(100);
return $gd->croppedResize(240,180);
}function generateTreeLarger($gd) {
$gd->setQuality(100);
return $gd->croppedResize(600,450);
}but I'm not sure where it should sit....any helpful hints?? cheers
-
Re: Preview: DataObjectManager module

24 March 2009 at 7:46pm
Hello
yesterday i installed the DataObjectManager.
BUt the Drag and Drop Function doesn't work.And second Question.
I Have a Tablefield "Status" which is defined by 0 (offline) or 1 (online).
Now i have the Table with Status on top but with 1 or nothing in the fields.
How can i set online and offline there?My current Code:
[bold]
function getCMSFields() {
$fields = parent::getCMSFields();
//related links tab
$manager = new DataObjectManager(
$this,
'LocationSubmissions',
'LocationSubmission',
array('Name' => 'Name','PLZ'=>'PLZ', 'Location' => 'Ort', 'Status' => 'Status'),
'getCMSFields_forPopup'
);
$manager->setFilter('Status','Nach Status sortieren',array(
'1' => 'online',
'0' => 'offline'
));
$fields->addFieldtoTab("Root.Content.Locationsubmission",$manager);
return $fields;}
[/bold]
Thanky you all!
-
Re: Preview: DataObjectManager module

24 March 2009 at 9:29pm Last edited: 24 March 2009 11:41pm
@Breastfed: in your mysite/_config.php add the line:
SortableDataObject::add_sortable_class('LocationSubmission');
That will get the drag and drop sorting working.
As for the status, EDIT...
Add this code to your LocationSubmissionpublic function getStatusField()
{
$value = $this->Status;
if($value) return "Online";
else return "Offline";
}
EDIT #2
Also, add to your manager:$manager = new DataObjectManager(
$this,
'LocationSubmissions',
'LocationSubmission',
array('Name' => 'Name','PLZ'=>'PLZ', 'Location' => 'Ort','Status''getStatusField' => 'Status'),
'getCMSFields_forPopup'
); -
Re: Preview: DataObjectManager module

24 March 2009 at 10:32pm
UncleCheese: Is there a way to make the upload directory be assets/[pagename]
I see that you can let the user specify the directory, but I want to force it to be a sub directory of assets based on the name of the page.
-
Re: Preview: DataObjectManager module

25 March 2009 at 3:15am Last edited: 25 March 2009 3:17am
@ drye -- Thank you for pitching in on support. It's nice to have gotten to a point with this thing where the whole thing isn't just on my shoulders anymore. To change the upload folder, use the allowUploadFolderSelection() method.
A reminder to everyone -- there is extensive documentation on DataObjectManager and all of its counterparts in the SS wiki. Please refer your questions there before simply saying something nondescript like "it doesn't work." I get dozens of support questions and feature requests every day, and it's very time consuming to go back and forth trying to get details. It is my goal to get this thing rock-solid and bug-free, so I appreciate any bug reports, but just make sure you all are doing your part and being as specific as possible and checking the documentation first.
Thanks for understanding.
-
Re: Preview: DataObjectManager module

25 March 2009 at 6:46am
We really appreciate the modules you've authored and the quality of support you give, Uncle Cheese. Thank you.
-
Re: Preview: DataObjectManager module

25 March 2009 at 7:14am
UncleCheese: Thank you! I am aware of the function: allowUploadFolderSelection(). However unless I misunderstand, this allows the user to select the upload directory. I was asking for a way to programaticaly set the upload directory, and in my case base it on the page name. If it isn't possible then maybe a feature request
Thanks again! I am happy to help with support whenever I can, the documentation is very nice, and I should point people to it more often. I did mention it in the IRC channel a few times.
Please let me know about the setting of the upload folder programaticaly, and forgive me if I misunderstand allowUploadFolderSelection().
-
Re: Preview: DataObjectManager module

25 March 2009 at 8:07am
Understood, Drye... The functionality you're speaking to is actually contained in the Upload class, and is completely external to the DataObjectManager or any other form field that allows uploading. You'll notice that a plain FileField, FileIFrameField, or ImageField will always upload to assets/Uploads by default, and that's because the property $upload_dir (something like that) in the Upload class is set to "Uploads" by default.
That said, anything is possible. I think a setUploadFolder() function would be very easy to implement. That could be very useful for things like $my_manager->setUploadFolder($this->URLSegment);
I see what you mean..
| 54239 Views | ||
| Go to Top | Next > |



