Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

New Stuff!


Go to End


4 Posts   1520 Views

Avatar
UncleCheese

Forum Moderator, 4102 Posts

26 June 2009 at 7:25am

Just Checked In:

AssetManager: Allows management of files directly to a page. No need to go through a dataobject. Usage:

$field->addFieldsToTab("Root.Content.Files", new AssetManager($this,"Files","MyFileClass"));

Where "Files" is the name of the file relation, and MyFileClass is the subclass of File that has a $has_one relationship with your page. If you want to use the File class directly, it would require modifying the File class to have that has_one relation, which requires a decorator. Still possible, though. If you choose to do if that way, the third argument defaults to "File" so all you need is:

new AssetManager($this,"Files");

AssetAdmin Support:

Because we can now manage files directly, it is now possible to use the AssetManager in the AssetAdmin interface. By default, this is turned on in the latest version of DataObjectManager in dataobject_manager/_config.php. Just set true/false with:

DataObjectManager::allow_assets_override($bool);

CSS Overrides

Not much to speak of here, but over time I'm going to be making updates to some of the weaker points of the Silverstripe core stylesheet. These updates will come in through dataobjectmanager_override.css. By default these overrides are turned off, but can be enabled in the config file.

DataObjectManager::allow_css_override(true);

Marking Permissions

For relation DataObjectManagers, you can now set the permissions required to alter the checked state of each item. Usage:

$my_relation_dataobjectmanager->setMarkingPermission("CMS_ACCESS_CMSMain");

By default, there are no permission restrictions on altering relations.

Other Stuff Mentioned Before But Still Cool

SWFUploadField: Now has speed calculation and countdown timer for uploads once five seconds have elapsed.

FileDataObjectManager: Now disables imports for file types that are not allowed.

DataObjectManager: Now has a "deselect all" option for HasOne/HasMany managers. This is especially useful for the HasOne manager, since it allows you to set a null value by clearing the radio buttons.

Avatar
Taffy

Community Member, 119 Posts

29 June 2009 at 9:01pm

Great work UC. I look forward to trying these new features.

Avatar
NickJacobs

Community Member, 148 Posts

30 June 2009 at 9:10am

Edited: 30/06/2009 9:10am

Awsome stuff!
I've been using DOM to do this on the page for the last couple of sites and it works great, so fantastic to see this as an even easier feature....

Could you possibly post some sample code for the setup of AssetManager??

cheers

Avatar
UncleCheese

Forum Moderator, 4102 Posts

30 June 2009 at 9:39am

Edited: 30/06/2009 9:41am

Yeah, basically it's

new AssetManager($this, 'MyFileField', 'FileClass');

"FileClass" will default to "File", but understand it's not common to have a has_many relationship with file because you would have to decorate the File object to have a has_one with your page. So most of the time you want to create some sort of class like:

MyFile extends File

static $has_one = array('MyPage' => 'MyPage');

to add the has_one there, so you're not altering the core File class.