Soring by URI

We want to sort our items by and we are using the following:

'Image Gallery' => ('items?'),


But it is not having any effect.
Is there something incorrect with the syntax?

I'm not sure where sortby and sortorder came from there, but you should use sort_field and sort_dir to specify sorting for an Omeka browse page. Also, Dublin Core Date would be specified by Dublin Core,Date, not

So, the URL should look more like items?sort_field=Dublin Core,Date. Ascending sort is the default, so you can leave sort_dir out.

Thanks John
This worked perfectly. I originally got the code from another post and I have corrected it there as well.

Here's another one I'm trying to figure out.
If I want to sort a specific collection by DC date?

I've tried some variations on this, but can not get to work.,sort_field=Dublin Core,Date

Any advice would be appreciated.


That URL will work just fine for sorting by date, but remember, Date is just a text field, so the sorting will only work properly if you have a reasonably regular format for your Date field, and effectively only if the content of the field is numeric.

The beginning of this other thread deals with specifying Date metadata in a way that will allow correct sorting as well as a "prettier" display.

Hi John,
The problem is that it does not work. I always get 0 results where I get 36 if I use

Oops, I missed a little problem in the URL you posted.

You don't separate those URL arguments with a comma like this: collection=3,sort_field=Dublin Core,Date.

Instead, you use an ampersand: collection=3&sort_field=Dublin Core,Date.

One more bit of complexity. I need to sort by a custom element (date field named sortdate) I added to the Still Image Item Type Metadata. Can you give me advice in the proper syntax. Here is what I have been trying Type Metadata,Still Image,sortdate

Many thanks in advance.

Try it without the "Still Image" part in the middle, just "Item Type Metadata,sortdate".

I tried this Type Metadata,sortdate
but it defaulted back to sorting by omeka item ID.
If you want to give it a try the testing access un and pw is team.

Is the name of the field exactly "sortdate"? (Including capitalization and spelling?)

In my own testing, things like sort_field=Item Type Metadata,Text work correctly, though that's obviously for the Text field.

There shouldn't be anything different about how the sorting should be specified for any other Item Type metadata field.

Good catch. Must be getting tired. I guess the title of this thread is telling in itelf.

Working url query is Type Metadata,datesort

Many thanks,

Hi John
One more sort instance. This time from a tag cloud link.
I'm trying
<?php echo tag_cloud($tags, uri('/items/browse?sort_field=Item Type Metadata,datesort&')); ?>
but I know I'm off in my syntax.
Any advice would be appreciated.

Unfortunately, tag_cloud isn't written to accept URL parameters in the URL given to it, it just tries to append ?tags=<tag name> to whatever string it's given.

The easiest way around this would be to make a copy of the tag_cloud function (it's in application/helpers/TagFunctions.php), put that copy in your theme's custom.php file, give it a unique name like custom_tag_cloud, and change the bit of code that creates the link to use an ampersand instead of a question mark.

if ($link) {
    $html .= '<a href="' . html_escape($link . '&tags=' . urlencode($tag['name'])) . '">';

Then, your call would look like

<?php echo custom_tag_cloud($tags, uri('items/browse?sort_field=Item Type Metadata,datesort')); ?>

Sweet! Worked like a charm and I learned a couple things along the way. Thank you for all of your generous assistance!