Does anyone have any tips on how to modify the php files so that the Items within each Collection can be sorted automatically by DC identifier element (in ascending order). We also want to do this with Tags, so the Items associated with each tag.
For collections we have tried the Item Order plugin, but would prefer to automate this only because some collections are large and we do not want to manually put them in order.
My first guess is to create a tiny plugin that makes use of the items_browse_sql hook to force in the sorting. Looking at the SimplePagesPlugin.php can give an example of setting up a small plugin using hooks.
The hook would take the $select object, and use the Item table’s applySorting function. Something along the lines of this (untested) code
public function hookItemsBrowseSql($select, $params)
{
$itemsTable = $this->_db->getTable('Item'); // get the table object
$itemsTable->applySorting($select, array('Dublin Core', 'Identifier'), 'ASC'); // use the table object's standard way to sort stuff
}
Without some additional checks on the route, though, that’ll make the sorting happen everywhere (and it might have side effects I haven’t anticipated). If that’s a problem, we can work on that as a second step once we get this part working.
Regarding the tags, I’m not quite following exactly what result you are after. (If you mean you want this to work when you click on a tag and get the list of items with that tag, the above should carry over to that.)
It seems to work for the items that display within each collection, but there are a handful of items that are still out of order. It is usually one at the beginning of the collection or in one case, one at the very end. All of the other items in the collections are in the correct order. This script, however, does not help us in ordering the items within a Tag group. We want to get a lit of items within the tag that are also sorted according to the DC:Identifier.