Customize admin/items/browse view

80 views
Skip to first unread message

lukas...@vbm.se

unread,
Feb 12, 2016, 5:58:36 AM2/12/16
to Omeka Dev
Hi group!

I'm new to Omeka, so I hope I can get some advice and tips from experienced users here. Not sure if I should write here or on Omeka's forum, so please let me know;)

What do you think is the best way of customizing the /admin/items page in Omeka?
  1. Choose what sort fields (and possibly their values) will be in the table
  2. Implement sorting by more than one sort field
I know it's bad idea to overwrite core theme files. The best I could find so far is to define route in my plugin to map URL 'items' => /plugin/items/browse. But it's not at all optimal, because I still have to clone (copy&paste) Omeka's core view file, so all updates needs to be merged.
Also sorting by more than one field will require rewriting the query parameter to something like sort_field[] or sort_field_0, sort_field_1,... and altering the search query in my plugin. 

So I'm very unsure what would the best way to go... 
Have you ever done this? Or do you know about some plugin not listed in Omeka's website that does this? 

I think the best option would be pull request to Omeka, but are Omeka developers interested in this kind of change in core? And if so, I would appreciate any advice or ideas all the more.

Thanks,
Lukas

Patrick Murray-John

unread,
Feb 12, 2016, 1:49:41 PM2/12/16
to omek...@googlegroups.com
Lukas,

For the vast majority of tasks like this, Omeka's hooks and filters can do the job in a plugin.

It sounds like some combination of the browse_params filter and the browse_sql and admin_items_browse hooks might provide what you are looking for

Patrick
--
You received this message because you are subscribed to the Google Groups "Omeka Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omeka-dev+...@googlegroups.com.
To post to this group, send email to omek...@googlegroups.com.
Visit this group at https://groups.google.com/group/omeka-dev.
For more options, visit https://groups.google.com/d/optout.

lukas...@vbm.se

unread,
Feb 16, 2016, 3:13:05 AM2/16/16
to Omeka Dev
Hi Patrick,

thank you for the hints. Perhaps I explained it in wrong way, but I'm talking more about the fields/columns in the table header/row-cells (starting here). Current filters and hooks like admin_items_browse help only with filling more data in some predefined columns/cells, it doesn't tell which columns should be displayed. Imagine if I wanted to remove 'Dublin Core:Creator' and add 2 new columns instead. More like this use case.
I saw in some other post, that I could manipulate content via Javascript, but it's not an option in this case. 

So it feels like I have to touch the admin/items/browse.php file. That's why I wasn't sure how should I proceed; if it's task for plugin or rather something that Omeka should have built-in. For now, I decided for plugin, since this will also need custom settings, and it would be too much changes in Omeka's core. But I still appreciate any thoughts or ideas you have about this.

Thanks
Lukas

John Flatness

unread,
Feb 16, 2016, 12:22:45 PM2/16/16
to omek...@googlegroups.com
Lukas,

You're right that the structure of the browse page and the hooks and
filters we provide doesn't really let you do much in the way of changing
or adding to the columns to be displayed. Patrick's answer was more
focused on the hooks you'd use to add "backend" support for multiple
simultaneous sorting.

It's possible to "theme" the admin side of Omeka like the public, but
there's no direct support for doing this and switching between themes,
and the sorting stuff would still have to be handled in a plugin (or by
editing the core). A possibly better option for the time being would be
to use the define_routes hook to reroute the items browse URL(s) to a
controller/action within your plugin. Then from there you have total
control over the output of that page without doing any core or admin
"theme" edits.

The other path would be to add either the functionality you're looking
at directly to the core (as you alluded to), or to add sufficient hooks
and filters to allow a plugin to more directly do what you're looking
at. We've had discussions in the past about re-working the way that
tables are generated to make it possible to filter each row, including
the headings, so it would be possible to change which columns are shown,
what order, etc. Doing that would mean making pretty significant changes
to pretty much all the tabular admin views, but could also open some
interesting possibilities.

Of course, the route of contributing changes to the core and relying on
those introduces possible significant delays for the code to get
accepted and released, and that could really be the deciding factor for you.

-John

On 02/16/2016 03:13 AM, lukas...@vbm.se wrote:
> Hi Patrick,
>
> thank you for the hints. Perhaps I explained it in wrong way, but I'm
> talking more about the fields/columns in the table header/row-cells
> (starting here
> <https://github.com/omeka/Omeka/blob/master/admin/themes/default/items/browse.php#L40>).
> Current filters and hooks like admin_items_browse help only with filling
> more data in some predefined columns/cells, it doesn't tell which
> columns should be displayed. Imagine if I wanted to remove 'Dublin
> Core:Creator' and add 2 new columns instead. More like this use case.
> I saw in some other post, that I could manipulate content via
> Javascript, but it's not an option in this case.
>
> So it feels like I have to touch the admin/items/browse.php file. That's
> why I wasn't sure how should I proceed; if it's task for plugin or
> rather something that Omeka should have built-in. For now, I decided for
> plugin, since this will also need custom settings, and it would be too
> much changes in Omeka's core. But I still appreciate any thoughts or
> ideas you have about this.
>
> Thanks
> Lukas
>
>
>
> Den fredag 12 februari 2016 kl. 19:49:41 UTC+1 skrev patrickmj:
>
> Lukas,
>
> For the vast majority of tasks like this, Omeka's hooks
> <http://omeka.readthedocs.org/en/latest/Reference/hooks/index.html>
> and filters
> <http://omeka.readthedocs.org/en/latest/Reference/filters/index.html> can
> do the job in a plugin.
>
> It sounds like some combination of the browse_params filter and the
> browse_sql and admin_items_browse hooks might provide what you are
> looking for
>
> Patrick
>
> --
> You received this message because you are subscribed to the Google
> Groups "Omeka Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to omeka-dev+...@googlegroups.com
> <mailto:omeka-dev+...@googlegroups.com>.
> To post to this group, send email to omek...@googlegroups.com
> <mailto:omek...@googlegroups.com>.

Lukas Pukas

unread,
Feb 17, 2016, 2:31:37 AM2/17/16
to Omeka Dev
Hi John,

yes the define_route hook, is perfect for the plugin way. Since I'm new to Omeka, I'm not confident I could write good enough code for pull request in same amount of time as I can write own plugin. So I will start it as plugin and see the actual size of code/changes needed. 

The idea about filtering each row sounds interesting... FYI: What I wanted was a filter that would allow me to alter the header fields, i.e. admin_items_browse_header (with some defaults, or locked fields like title). And then for each cell in next rows I expected there will be hook similar to those you have, additionally telling me also the field name (same as in header) I'm in. Then I realised if every row will be torn into pieces like this, it will be definitely performance hit. So your idea of filtering whole row could be more optimal. I will have to study this more, but I really appreciate both your and Patrick inputs.

Thanks,
Lukas
Reply all
Reply to author
Forward
0 new messages