Created
November 22, 2011 19:26
-
-
Save Zauberfisch/1386646 to your computer and use it in GitHub Desktop.
[Silverstripe] Display ID and Filesize in AssetsAdmin (Works with and without DataObjectManager!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (class_exists('AssetManager')) DataObjectManager::allow_assets_override(false); // if DOM is installed | |
Object::add_extension('Folder', 'myAssetsFolderDecorator'); | |
if (class_exists('AssetManager')) DataObjectManager::allow_assets_override(true); // if DOM is installed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class myAssetsFolderDecorator extends DataObjectDecorator { | |
public function updateCMSFields(Fieldset $fields) { | |
$AssetsManager = $fields->fieldByName('Root')->fieldByName('Files')->fieldByName('Files'); | |
$AssetsManager->setFieldList(array('ID' => 'ID', 'Title' => 'Title', 'Filename' => 'Filename', 'getSize' => 'Size')); | |
if (class_exists('AssetManager') && is_a($AssetsManager, 'AssetManager')) { | |
// if DOM is installed | |
$AssetsManager->setColumnWidths(array( | |
'ID' => 5, | |
'Title' => 20, | |
'Filename' => 65, | |
'getSize' => 10 | |
)); | |
} | |
return $fields; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment