Sort Browse Results plugin

Will the Sort Browse Results work for Omeka 1.2.1? Has anyone tried the Sort Browse Results plugin with the latest version of Omeka?

I'm running v.1.2.1 and the old plugin seems to work. I added the Sort Browse Results code into /mytheme/items/browse.php. Even added a line to sort by Creator:

<td class="name <?php echo $sortBy->get_cssclass("name"); ?>"><a href="<?php echo $sortBy->get_link('dc.creator'); ?>" title="Sort by name">Names</a></td>

I may need to add some code the CSS, though, to make it display better.

Great, glad to hear it.


I am using the Sort Browse Results plugin, but am not sure how to get it to automatically (by default) sort results by dc.title, without having to add the links for users. Any idea how to do this? I have read the documentation, but can't seem to get it to sort without having a user click on the links.

Hi cabusara,

Unfortunately I don't think the Sort Browse Results plugin has options to set the default sorting to a specific field. We are planning to put sortable columns in the Omeka core in a future release, so we may look into the possibility of adding an option for a default sort.

In the meantime, it would be possible, to modify the plugin to sort by a specific field instead of Omeka's defaults. (Just to clarify, I didn't develop this plugin, so the plugin's developer may have other recommendations. And if you did need to upgrade this plugin for whatever reason, you may need to remember your changes before upgrading.)

If you're up for it, try modifying the plugin.php file, and replace this the following around line 59:

    // do nothing if $_GET['sortby'] is empty

with this:

} else {
        // Defaults to the Title field in Dublin Core.
        sort_by_dc($select, 'title');

This is in the sortbrowse function. The full function should read:

function sortbrowse($select, $params)
    // determine whether to sort using the element_texts (Dublin Core)
    // or
    // Items table (item_type | modified | added | collection_id)
    // 'type' defaults to items table
    $sortTerm = explode("."  , $_GET['sortby'] ,2 );
    if (sizeof($sortTerm) === 2) {
        $includesElementSet = true;
    } else if ($_GET['sortby']){
        $isSingleValue = true;

    if ($includesElementSet) {
        $sortOrder = strtolower($sortTerm[1]);
        if ($sortTerm[0] === 'dc') {
            sort_by_dc($select, $sortOrder);
        } else if($sortTerm[0] === 'omeka') {
            sort_by_omeka($select, $sortOrder);
    }  else if ($isSingleValue) {
        $sortOrder = strtolower($sortTerm[0]);
        if ($sortOrder === 'type'){
            //  use items table (default is omeka.item_type)
            sort_by_omeka($select, 'item_type_id');
        } else {
            // tries element_texts table, then items table
            sort_by_dc($select, $sortOrder);
    } else {
        // Defaults to the Title field in Dublin Core.
        sort_by_dc($select, 'title');

All we've done here is provide a default option if there is not 'sortby' parameter, which will be the Dublin Core Title field. I just tried this on the plugin and it works for me.

Hope this helps!

Brilliant, it works, of course!

Glad to help!