Last active
January 3, 2017 08:09
-
-
Save jeremyboggs/3319ce091a751912101943dc1f73c8c6 to your computer and use it in GitHub Desktop.
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 CustomItemsBrowsePlugin extends Omeka_Plugin_AbstractPlugin | |
{ | |
protected $_hooks = array( | |
'items_browse_sql' | |
); | |
public function hookItemsBrowseSql($args) { | |
$select = $args['select']; | |
$sort_string = "CASE WHEN et_sort.text REGEXP '<[^>]*>' = 1 THEN TRIM(SUBSTR(et_sort.text, INSTR(et_sort.text ,' '))) ELSE et_sort.text END ASC"; | |
$select->reset(Zend_Db_Select::ORDER); | |
$sort_order = new Zend_Db_Expr($sort_string); | |
$select->order($sort_order); | |
get_db()->getTable('Item')->applySorting($select, 'Dublin Core,Title', 'ASC'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@luku Thanks! For the correction, and for the suggestion on
$sortDir
. Yeah, as written this would fail on nested HTML, which is entirely possible to have. And agreed about the usefulness of a sort_key field.