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

Tip: Use SiteConfig to enable DOM in Assets


Go to End


1142 Views

Avatar
x75

Community Member, 43 Posts

21 December 2010 at 3:08am

Edited: 21/12/2010 3:08am

Hi,

with DOM enabled users can not drag and drop files to other folders in "Files & Images".
There is a setting to disable DOM for the assets folder: DataObjectManager::allow_assets_override

Since one of our customers wants dom enabled most the time, but sometimes needs to move files we added a config option for him:
Create a file named "CustomAssetAdmin.php":

<?php
 class CustomAssetAdmin extends DataObjectDecorator {
   function init() { 
		$config = SiteConfig::current_site_config(); 
		DataObjectManager::allow_assets_override($config->DomAllowAssetsOverride);
   } 
}
?>

Add the option to your siteconfig: "CustomSiteConfig.php":

<?php
 class CustomSiteConfig extends DataObjectDecorator {
     
    function extraStatics() {
        return array(
            'db' => array(
				'DomAllowAssetsOverride' => 'boolean'
			)
        );
    }
   
    public function updateCMSFields(FieldSet &$fields) {
      $fields->addFieldToTab('Root.Settings', new CheckBoxField('DomAllowAssetsOverride','DOM in "Dateien und Bilder" verwenden?'));	    }
}
?>

Add these to your _config.php

DataObject::add_extension('SiteConfig', 'CustomSiteConfig');
Object::add_extension('AssetAdmin', 'CustomAssetAdmin');

That gives your users the option to enable/disable DOM for the assets folder on demand.

Johannes