Hooks

This page is outdated

The information on this page concerns an old or obsolete version of Omeka. If you are using a more recent version, instead see Hooks on Omeka's Read the Docs site.

The following plugin hooks are part of Omeka's Plugin API:

General Hooks

These general plugin hooks are used for basic plugin features, installing, configuring, and controlling access.

Theme Hooks

Theme hooks allow plugins to add content to various sections of Omeka's interface. A plugin using one of these hooks can output HTML directly onto Omeka pages in a way that works across many different themes.

Admin Theme

Public Theme

Database Hooks

Generic Record Hooks

The following hooks are fired after or before any model being used, regardless of what model they are. For example, after_save_record hook is fired when after both an item being saved, as well as a collection or file.

Specific Record Hooks

Database hooks that begin with "before_" and "after_" are implied and exist for every model that is defined, including models defined by plugins. Below are just a few of the available before/after hooks. The available events are save, save_form, delete, insert, update, and validate.

Implied hook structure

[before|after]_[event]_[record name]

Example of implied hook in use

Pre- Omeka 1.5:

<?php add_plugin_hook('after_save_item', 'plugin_name_after_save_item'); ?>

Omeka 1.5 and later:

class MyPlugin extends Omeka_Plugin_Abstract
{
    protected _$hooks = array(
        'after_save_item'
    );
 
    public function afterSaveItem($item)
    {
        //do something with item 
 
    }
 
}

For example, below are all the possible implied hooks for Items. These hooks will only fire when the corresponding action has occurred to an Item record.

  • after_save_item
  • before_save_item
  • before_save_form_item
  • after_save_form_item
  • before_delete_item
  • after_delete_item
  • before_insert_item
  • after_insert_item
  • before_update_item
  • after_update_item
  • before_validate_item
  • after_validate_item

Miscellaneous Hooks

Browse/show hooks

Additional hooks exist for browse and show pages for many record types. browse_record hooks are passed an array of that record type. show_record hooks are passed the record.

Here are some examples:

  • show_itemtype
  • browse_itemtypes
  • browse_items
  • browse_tags
  • browse_collections
  • browse_users
  • show_item
  • show_user
  • show_collection