diff --git a/biblio.admin.inc b/biblio.admin.inc index be836ad..6fdd79f 100644 --- a/biblio.admin.inc +++ b/biblio.admin.inc @@ -364,6 +364,14 @@ function biblio_admin_settings() { ) ); + $form['sort']['biblio_secondary_sort_by_tid'] = array( + '#type' => 'checkbox', + '#title' => t('Sort by year : secondary sort by type id'), + '#return_value' => 1, + '#default_value' => variable_get('biblio_secondary_sort_by_tid', 1), + '#description' => t('When sorting by type, second sorting criterion is type id instead of type name') + ); + $form['sort']['biblio_enumerate_references'] = array( '#type' => 'checkbox', '#title' => t('Enumerate references'), diff --git a/biblio.pages.inc b/biblio.pages.inc index 5975fcf..623bec9 100644 --- a/biblio.pages.inc +++ b/biblio.pages.inc @@ -133,7 +133,10 @@ function biblio_build_query($arg_list) { switch ($sort_attrib['sort']) { case 'type': - $sortby = "ORDER BY bt.name %s, b.biblio_year DESC "; + if (variable_get('biblio_secondary_sort_by_tid',0)) + $sortby = "ORDER BY bt.tid %s, b.biblio_year DESC "; + else + $sortby = "ORDER BY bt.name %s, b.biblio_year DESC "; break; case 'title': //$sortby = "ORDER BY SUBSTRING(n.title,1,3) %s, b.biblio_year DESC ";