Well, a default sort in this case doesn't seem to work, as it doesn't affect the order the objects are viewed in the DOM view in the CMS, and I'm already doing a custom function for displaying them on a page due to using the paging feature.
So for my controller/template (NewsPage.php):
function PagingArticles() {
if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) {
$_GET['start'] = 0;
}
$SQL_start = (int)$_GET['start'];
$doSet = DataObject::get('NewsArticle', "`NewsPageID` = '{$this->ID}'", "SortOrder DESC", "", "$SQL_start, 10");
return $doSet ? $doSet : false;
}
What I'm going for is mimicking this behavior in the view in the CMS. I thought I'd be all clever, and add SortOrder to the table view (NewsPage.php):
$fields = parent::getCMSFields();
$NewsManager = new DataObjectManager(
$this,
'Articles',
'NewsArticle',
array('SortOrder' => 'SortOrder', 'Date' => 'Date', 'Contact' => 'Contact', 'Heading' => 'Heading'),
'getCMSFields_forPopup'
);
And I was excited to find that it does indeed show a column with the sort ID's from the database, however clicking on the heading to sort with that doesn't work. Any other header does. So I'm not sure what is going on there.
Hopefully that gives you an idea of what I'm trying to do. Any further ideas?
I'll warn you I'm also having some trouble with the CustomSearchForm you posted about elsewhere, but I got more digging to do with that, and I'll post in that thread when I finally give up. :)