Sorting on "show" pages


I'm using SimplePages, in the SimplePages show.php file I'm displaying collections based on the page, however, I'm trying to find a way to sort the collection items either by a field or directionally.

Any ideas would be great, thanks!

How are you actually showing the collections?

Whatever you're using to get the collections should be able to take parameters for sorting.

Well, the sorting parameters don't seem to be working. Possibly because the sorting parameters only work for "browse"?


For example,

<?php if ($page->slug == 'participants') : ?>

    	<ul class="list-col">
			$items = get_items(array('collection' => 1));

				<?php echo link_to_item(); ?><br/>
				<?php echo item('Item Type Metadata', 'Affiliation'); ?>

		<?php endwhile; ?>


    <?php endif; ?>

So, you're displaying items from a particular collection, not collections.

Anyway, you're using get_items. As you can see on the documentation for get_items, the function takes sort_field and sort_dir options, so you just need to specify those to get sorted results.

Yes, I'm aware of those parameters, and it hasn't worked when I specify them. I believe there is a difference between "browse" vs. "show", no? From what I've read in the docs and forums, the sort_field and sort_dir only work when "browsing" a collection. I'm modifying show.php in SimplePlugins.

If I'm wrong, more insight would be great!


Where are you specifying those parameters? There's nothing in your code to that effect.

The sort_field and sort_dir parameters are automatically read out of the URL for "browse" pages.

That's totally separate from using the parameters in code when calling a function like get_items, which won't work any differently when used on a "show" page.

They aren't specified in the code above, I removed what I had been working with.

Is this correct syntax, it is not working?
$items = get_items(array('collection' => 1, 'sort_field' => 'Dublin Core,Subject'));


That syntax exactly works correctly for me.

What's happening, is the parameter not affecting the output at all, or is the sorting just "off" in some way?

Also, I don't think you've mentioned: what version of Omeka are you using?

The parameter isn't affecting the output at all, nothing I've tried has affected it.

The Omeka version is 1.2.1, which I'm guessing might be the problem?

Thanks for your help.


As you'll see in the documentation on those sorting parameters, they were added in Omeka 1.3.