Browse Random Items

I’am looking for a solution to display a random sort order when browsing the content of a collection.
Thanks for your help

Just to make sure I’m seeing the issue correctly, are you talking about a page for the Collection that shows some of the items in that collection, with a URL like Omeka/collections/show/4? Or something with a URL like Omeka/items/browse?collection=4?

The solutions might be similar, but knowing exactly which kind of page will be helpful. It might be something that can be addressed in a theme modification, or might need a plugin to change the queries, depending on which page type you want to modify. It’s the difference of whether it starts with items or collections.

something with a URL like Omeka/items/browse?collection=4 - or without the collection like in “Omeka/items/browse” - Thanks a lot and kind regards

One way at it is with a very basic plugin that uses the browse_params filter. Put this code in the plugins folder, in a directory called RandomItems, in a file in that directory called RandomItemsPlugin.php

This will make all items browse queries be random. If we need to distinguish between different pages, we can sort that out.


class RandomItemsPlugin extends Omeka_Plugin_AbstractPlugin
    public $_filters = array (
    public function filterItemsBrowseParams($params)
        $params['sort_field'] = 'random';
        return $params;

Wow, this was exactly what I wanted it works fine. Thank you so much for your help!!! Kind regards from Berlin.

Is there a simple way to make this plugin only sort randomly for the view Omeka/items/browse? As is it makes all browse queries random. I’m imagining users seeing a random order on the main browse page but also being able to sort by things like title, date, etc.

I just realized I can use Omeka/items/browse?&sort=random to sort randomly. Unfortunately, this appears to sort in the same random order whenever the page is refreshed so I’m still searching for a way to make it newly random each time the page is visited.

?sort_field=random should get you random sorting that differs every time.

Fantastic, that solves my problem precisely. Thank you!