Skip to content

Commit

Permalink
FIX: Resolve issue of not being able to attach documents on draft pages
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed Jan 10, 2014
1 parent 50aa550 commit 0fb0410
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions code/cms/DMSDocumentAddController.php
Expand Up @@ -30,12 +30,16 @@ static function add_allowed_extensions($array = null) {

/**
* Custom currentPage() method to handle opening the 'root' folder
*
* @return
*/
public function currentPage() {
$id = $this->currentPageID();

if($id && is_numeric($id) && $id > 0) {
return DataObject::get_by_id('SiteTree', $id);
return Versioned::get_by_stage('SiteTree', 'Stage', sprintf(
'ID = %s', (int) $id
))->first();
} else {
// ID is either '0' or 'root'
return singleton('SiteTree');
Expand All @@ -59,7 +63,6 @@ public function getEditForm($id = null, $fields = null) {
Requirements::css(DMS_DIR.'/css/DMSMainCMS.css');

$page = $this->currentPage();

$uploadField = DMSUploadField::create('AssetUploadField', '');
$uploadField->setConfig('previewMaxWidth', 40);
$uploadField->setConfig('previewMaxHeight', 30);
Expand Down

0 comments on commit 0fb0410

Please sign in to comment.