How to retrieve the full set of values for a given property

I want to create a kind of quick-filter select box in a theme that allows the user to pick from all in-use values for a given property. eg, if there were a total of 3 items existing in Omeka with 3 different values for Spatial Coverage, those 3 would all be displayed in a select box and the user could pick a value.

Obviously this won’t scale to huge collections, but that’s not an immediate concern for this project.

What would be a good way to do this? Are there any built in methods for this in the PHP API? It has to be presented in the theme eventually, but I am happy to put auxiliary code in a module. At the moment the only way that I can think is to do search() and read() in a loop using the API manager, which seems quite cumbersome.

There’s no interface to that built into the API.

Since you’re OK doing a module, I think the way to go would be accessing the EntityManager directly and running a DQL query, something like SELECT DISTINCT from the values table, specifying the ID of the property to look at.

1 Like

This is what does the module Reference, but for blocks of page. Nevertheless, you can reuse the view helper.

Whatever, I’m implementing this in my next version of the new resource template management in a few week. Nevertheless, it will probably work only for resource with a template.