Skip to content
Jim Safley edited this page Apr 27, 2015 · 13 revisions

Introduction

You can extend the functionality of Omeka S by writing an add-on component called a module. Zend Framework 2 provides a substantial framework for writing modules, but Omeka S provides extra structure that makes the modules installable, upgradeable, and integratable.

Directory Structure

At its most basic level, a module directory is structured like so:

MyModule/
    Module.php
    config/
        module.ini
        module.config.php
    src/
        <library-directories-and-files>
    view/
        <module-namespace>/
            <controller-directories>/
                <action-files>.phtml

The name of the module directory ("MyModule" above) is significant. It must be a reasonably unique, concise, and descriptive name of your module in CamelCase format.

Module.php

The Module.php file is required. It provides the methods needed to integrate your custom functionality with Omeka S.

config/module.ini

Every module must have an INI file, a file containing basic information about the module. The file must be named module.ini and be saved in your module's config/ directory.

  • name (required): The human-readable name of the module
  • version (required): The version of the current code state
  • author (optional): The author of the module
  • configurable (optional): Whether the module is configurable, true or false
  • description (optional): A description of the module
  • module_link (optional): An absolute URL to a page about the module
  • author_link (module): An absolute URL to a page about the author
name         = "My Module"
version      = "1.0"
author       = "My Organization"
configurable = true
description  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
module_link  = "http://my-organization.com/my-module"
author_link  = "http://my-organization.com"

Make a Module Configurable

To enable module configuration, remember to set configurable = true in config/module.ini and use the getConfigForm() and handleConfigForm() methods in your module class, like below:

use Zend\View\Model\ViewModel;
use Zend\Mvc\Controller\AbstractController;

class Module extends AbstractModule
{
    /** Module body **/

    /**
     * Get this module's configuration form.
     *
     * @param ViewModel $view
     * @return string
     */
    public function getConfigForm(ViewModel $view)
    {
        return '<input name="foo">';
    }

    /**
     * Handle this module's configuration form.
     *
     * @param AbstractController $controller
     * @return bool False if there was an error during handling
     */
    public function handleConfigForm(AbstractController $controller)
    {
        return true;
    }
}