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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Tip: Use SiteConfig to enable DOM in Assets


Reply


836 Views

Avatar
x75

Community Member, 42 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