How To: Plugin Hooks

Jump to: navigation, search

Contents

append_to_item_form

Append content to the forms in the administrative item add and item edit pages, immediately before the footer.

Available arguments:

  • $item: the item object

When fired:

  • In the /admin/items/add and /admin/items/edit pages, immediately before the foot() function.

Where fired:

  • ./admin/themes/default/items/form.php

Example plugin code:

<?php
add_plugin_hook('append_to_item_form', 'pluginFunctionName');
function pluginFunctionName($item) {
    // Content goes here
}

append_to_item_form_tags

Append content to the tagging section of the forms in the administrative item add and item edit pages.

Available arguments:

  • $item: the item object

When fired:

  • In the /admin/items/add and /admin/items/edit pages, immediately after the tagging section.

Where fired:

  • ./admin/themes/default/items/form.php

Example plugin code:

<?php
add_plugin_hook('append_to_item_form_tags', 'pluginFunctionName');
function pluginFunctionName($item) {
    // Content goes here
}

append_to_item_form_upload

Append content to the file upload section of the forms in the administrative item add and item edit pages.

Available arguments:

  • $item: the item object

When fired:

  • In the /admin/items/add and /admin/items/edit pages, immediately after the file upload section.

Where fired:

  • ./admin/themes/default/items/form.php

Example plugin code:

<?php
add_plugin_hook('append_to_item_form_upload', 'pluginFunctionName');
function pluginFunctionName($item) {
    // Content goes here
}

append_to_item_show

Append content to the administrative item show page, immediately before the footer.

Available arguments:

  • $item: the item object

When fired:

  • In the /admin/items/show page, immediately before the foot() function.

Where fired:

  • ./admin/themes/default/items/show.php

Example plugin code:

<?php
add_plugin_hook('append_to_item_show', 'pluginFunctionName');
function pluginFunctionName($item) {
    // Content goes here
}

append_to_items_browse

Append content to the administrative items browse page, immediately before the footer.

Available arguments:

  • $items: an array of item objects

When fired:

  • In the /admin/items/browse page, immediately before the foot() function.

Where fired:

  • ./admin/themes/default/items/browse.php

Example plugin code:

<?php
add_plugin_hook('append_to_items_browse', 'pluginFunctionName');
function pluginFunctionName($items) {
    // Content goes here
}

append_to_settings_form

Append content to the administrative settings page, immediately before the footer.

Available arguments:

  • [none]

When fired:

  • In the /admin/settings/index page, immediately before the foot() function.

Where fired:

  • ./admin/themes/default/settings/edit.php

Example plugin code:

<?php
add_plugin_hook('append_to_settings_form', 'pluginFunctionName');
function pluginFunctionName() {
    // Content goes here
}

browse_collections

Add functionality while browsing collections in the admin and public interfaces. Do not output content.

Available arguments:

  • $items: an array of collection objects

When fired:

  • In the collections/index and collections/browse pages, immediately before the page is rendered.

Where fired:

  • ./application/libraries/Omeka/Controller/Action.php; Omeka_Controller_Action class; browseAction() method.

Example plugin code:

<?php
add_plugin_hook('browse_collections', 'pluginFunctionName');
function pluginFunctionName($collections) {
    // Code goes here
}

browse_entities

Add functionality while browsing entities (names) in the admin interface. Do not output content.

Available arguments:

  • $entities: an array of entity objects

When fired:

  • In the entities/index and entities/browse pages, immediately before the page is rendered.

Where fired:

  • ./application/libraries/Omeka/Controller/Action.php; Omeka_Controller_Action class; browseAction() method.

Example plugin code:

<?php
add_plugin_hook('browse_entities', 'pluginFunctionName');
function pluginFunctionName($entities) {
    // Code goes here
}

browse_exhibits

Add functionality while browsing exhibits in the admin and public interfaces. Do not output content.

Available arguments:

  • $exhibits: an array of exhibit objects

When fired:

  • In the exhibits/index and exhibits/browse pages, immediately before the page is rendered.

Where fired:

  • ./application/libraries/Omeka/Controller/Action.php; Omeka_Controller_Action class; browseAction() method.
  • ./application/controllers/ExhibitsController.php; ExhibitsController class; browseAction() method

Example plugin code:

<?php
add_plugin_hook('browse_exhibits', 'pluginFunctionName');
function pluginFunctionName($exhibits) {
    // Code goes here
}

browse_items

Add functionality while browsing items in the admin and public interfaces. Do not output content.

Available arguments:

  • $items: an array of item objects

When fired:

  • In the items/index and items/browse pages, immediately before the page is rendered.

Where fired:

  • ./application/libraries/Omeka/Controller/Action.php; Omeka_Controller_Action class; browseAction() method.
  • ./application/controllers/ItemsController.php: ItemsController class, browseAction() method; Immediately before the browse page is rendered.

Example plugin code:

<?php
add_plugin_hook('browse_items', 'pluginFunctionName');
function pluginFunctionName($items) {
    // Code goes here
}

browse_tags

Add functionality while browsing tags in the admin and public interfaces. Do not output content.

Available arguments:

  • $tags: an array of tag objects
  • $for: the tag type, currently 'Item' or 'Exhibit'

When fired:

  • In the tags/index and tags/browse pages, immediately before the page is rendered.

Where fired:

  • ./application/libraries/Omeka/Controller/Action.php; Omeka_Controller_Action class; browseAction() method.
  • ./application/controllers/TagsController.php; TagsController class; browseAction() method

Example plugin code:

<?php
add_plugin_hook('browse_tags', 'pluginFunctionName');
function pluginFunctionName($tags, $for) {
    // Code goes here
}

browse_types

Add functionality while browsing types in the admin interface. Do not output content.

Available arguments:

  • $types: an array of type objects

When fired:

  • In the types/index and types/browse pages, immediately before the page is rendered.

Where fired:

  • ./application/libraries/Omeka/Controller/Action.php; Omeka_Controller_Action class; browseAction() method.

Example plugin code:

<?php
add_plugin_hook('browse_types', 'pluginFunctionName');
function pluginFunctionName($types) {
    // Code goes here
}

browse_users

Add functionality while browsing users in the admin interface. Do not output content.

Available arguments:

  • $users: an array of user objects

When fired:

  • In the users/index and users/browse pages, immediately before the page is rendered.

Where fired:

  • ./application/libraries/Omeka/Controller/Action.php; Omeka_Controller_Action class; browseAction() method.

Example plugin code:

<?php
add_plugin_hook('browse_users', 'pluginFunctionName');
function pluginFunctionName($users) {
    // Code goes here
}

initialize

Add functionality when the plugin is initialized. Do not output content.

Available arguments:

  • none

When fired:

  • It only fires every time Omeka processes a request. Specificially, it only occurs when the PluginManager initializes. Note: It does not fire when the plugin is activated or re-activated.

Where fired:

  • ./application/libraries/plugin.php; PluginBroker class; __construct() method.

Example plugin code:

<?php
add_plugin_hook('initialize', 'pluginFunctionName');
function pluginFunctionName() {
    // Code goes here
}


install

Add functionality when plugin is installed for the first time. Do not output content.

Available arguments:

  • none

When fired:

  • It only fires when Omeka detects a new plugin folder. Note: It does not fire when the plugin is activated or re-activated.

Where fired:

  • ./application/libraries/plugin.php; PluginBroker class; install($plugin) method.

Example plugin code:

<?php
add_plugin_hook('install', 'pluginFunctionName');
function pluginFunctionName() {
    // Code goes here
}


make_item_public

Add functionality when an item is made public (after submitting the items browse form). Do not output content.

Available arguments:

  • $item: the item object

When fired:

  • In the /admin/items/powerEdit page, when an item is made public.

Where fired:

  • ./application/controllers/ItemsController.php; ItemsController class; powerEditAction() method

Example plugin code:

<?php
add_plugin_hook('make_item_public', 'pluginFunctionName');
function pluginFunctionName($item) {
    // Code goes here
}

prepend_to_settings_form

Prepend content to the administrative settings page, immediately after the header.

Available arguments:

  • [none]

When fired:

  • In the /admin/settings/index page, immediately after the head() function.

Where fired:

  • ./admin/themes/default/settings/edit.php

Example plugin code:

<?php
add_plugin_hook('prepend_to_settings_form', 'pluginFunctionName');
function pluginFunctionName() {
    // Content goes here
}

show_exhibit

Add functionality while viewing an exhibit on the admin and public interfaces. Do not output content.

Available arguments:

  • $exhibit: the exhibit object
  • $section: the section object
  • $page: the page object

When fired:

  • In the exhibits/:exhibit_slug/:section_slug/:page page, immediately before the page is rendered.

Where fired:

  • ./application/controllers/ExhibitsController.php; ExhibitsController class; showAction() and summaryAction() methods

Example plugin code:

<?php
add_plugin_hook('show_exhibit', 'pluginFunctionName');
function pluginFunctionName($exhibit, $section, $page) {
    // Code goes here
}

show_exhibit_item

Add functionality while viewing an exhibit item on the admin and public interfaces. Do not output content.

Available arguments:

  • $item: the item object
  • $exhibit: the exhibit object

When fired:

  • In the exhibits/:exhibit_slug/:section_slug/item/:item_id page, immediately before the page is rendered.

Where fired:

  • ./application/controllers/ExhibitsController.php; ExhibitsController class; showitemAction() method

Example plugin code:

<?php
add_plugin_hook('show_exhibit_item', 'pluginFunctionName');
function pluginFunctionName($item, $exhibit) {
    // Code goes here
}

load_navigation

Internal hook, not for use in plugins.

Available arguments:

  • 'users', 'settings', 'main', 'archive'

Where fired:

  • ./admin/themes/default/common/users-nav.php
  • ./admin/themes/default/common/settings-nav.php
  • ./admin/themes/default/common/header.php
  • ./admin/themes/default/common/archive-nav.php
fire_plugin_hook('load_navigation', 'users');
fire_plugin_hook('load_navigation', 'settings');
fire_plugin_hook('load_navigation', 'main');
fire_plugin_hook('load_navigation', 'archive');


show_collection

Add functionality while showing a collection in the admin and public interfaces. Do not output content.

Available arguments:

  • $collection: the collection object

When fired:

  • In the collections/show page, immediately before the page is rendered.

Where fired:

  • ./application/libraries/Omeka/Controller/Action.php; Omeka_Controller_Action class; browseAction() method.

Example plugin code:

<?php
add_plugin_hook('show_collection', 'pluginFunctionName');
function pluginFunctionName($collection) {
    // Code goes here
}

show_item

Add functionality while showing an item in the admin and public interfaces. Do not output content.

Available arguments:

  • $item: the item object

When fired:

  • In the items/show page, immediately before the page is rendered.

Where fired:

  • ./application/libraries/Omeka/Controller/Action.php; Omeka_Controller_Action class; browseAction() method.


Example plugin code:

<?php
add_plugin_hook('show_item', 'pluginFunctionName');
function pluginFunctionName($item) {
    // Code goes here
}

show_type

Add functionality while showing an item type in the admin interface. Do not output content.

Available arguments:

  • $type: the type object

When fired:

  • In the types/show page, immediately before the page is rendered.

Where fired:

  • ./application/libraries/Omeka/Controller/Action.php; Omeka_Controller_Action class; browseAction() method.

Example plugin code:

<?php
add_plugin_hook('show_type', 'pluginFunctionName');
function pluginFunctionName($type) {
    // Code goes here
}


Undocumented Plugin Hooks

  • add_routes
  • after_render_page
  • after_upload_file
  • append_to_search_form
  • append_to_file_path
  • append_to_file_web_path
  • before_render_page
  • before_update_item
  • config
  • config_form
  • item_browse_sql
  • make_item_public
  • remove_item_tag
  • theme_footer
  • theme_header


./application/libraries/Omeka/Controller/Action.php

fire_plugin_hook('before_render_page', $page, $vars);
fire_plugin_hook('after_render_page', $page, $vars);

./application/libraries/Omeka/Record.php

fire_plugin_hook($hook, $this);

./application/libraries/plugins.php

function fire_plugin_hook()

./application/core/core.php

fire_plugin_hook('add_routes', $router);

./application/helpers/Functions.php

fire_plugin_hook('theme_header');
fire_plugin_hook('theme_footer');

./application/helpers/FormFunctions.php

fire_plugin_hook('append_to_search_form');

./application/models/Taggable.php

fire_plugin_hook($hook,  $this->record, $diff['removed'], $entity);
fire_plugin_hook('add_' . strtolower(get_class($this->record)) . '_tag',  $this->record, $diff['added'], $entity);

./application/models/File.php

fire_plugin_hook('append_to_file_path', $path);
fire_plugin_hook('append_to_file_web_path', $path);

./application/models/Item.php

fire_plugin_hook('make_item_public', $this);
fire_plugin_hook('remove_item_tag',  $tagToDelete->name, $current_user);
fire_plugin_hook('after_upload_file', $file, $this);

./application/models/ItemTable.php

fire_plugin_hook('item_browse_sql', $select, $params);


Personal tools

Toolbox