ENHANCEMENT: Show list of documents when page is selected in dropdown

This commit is contained in:
Andrew O'Neil 2012-08-14 13:59:08 +12:00
parent a6f8b83e1a
commit be809ac2c9
3 changed files with 27 additions and 0 deletions

View File

@ -196,6 +196,23 @@ class DMSDocumentAddController extends LeftAndMain {
return json_encode($return);
}
public function documentlist() {
$page = DataObject::get_by_id('SiteTree', (int) $_GET['pageID']);
if($page && $page->Documents()) {
$list = '<ul>';
foreach($page->Documents() as $document) {
$list .= '<li>' . $document->ID . ' - ' . Convert::raw2xml($document->Title) . '</li>';
}
$list .= '</ul>';
return $list;
} else {
return '<p>There are no documents attached to the selected page.</p>';
}
}
}

View File

@ -40,5 +40,11 @@
}
});
$('.document-add-existing input[name=PageSelector]').entwine({
onchange: function(event) {
$(this).closest('.document-add-existing').find('.document-list').load('admin/pages/adddocument/documentlist?pageID=' + $(this).val());
}
});
});
}(jQuery));

View File

@ -12,6 +12,10 @@
<span>or Add from page</span>
$fieldByName(PageSelector)
<div class="document-list">
</div>
</div>
<div class="ss-assetuploadfield">