Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Tip: Use SiteConfig to enable DOM in Assets

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 793 Views
  • x75
    Avatar
    Community Member
    42 Posts

    Tip: Use SiteConfig to enable DOM in Assets Link to this post

    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

    793 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.