About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


Warning: This page has not been updated in over over a year and may be outdated or deprecated.
legacy:vufind_1.x_developer_manual:building_a_module

This is an old revision of the document!


Building A Module

:!: This page refers to VuFind 1.x; for notes on the architecture of newer versions, see the current customization page.

Current Modules

Module Notes
Search Provides core search functionality
Record Provides a web page for each record
MyResearch A portal for users to save and organize resources in a central location
Help Provides context sensitive help for the users
Author Provides a web page for each author and harvests biographical information from Wikipedia
OAI Provides an OAI content provider service to allow for harvesting of records (currently incomplete)

Building Custom Modules

Back End Logic

Modules are very easy to build. All you need to do to integrate your code with the system is to create a directory under the web/services directory with the name of the module. Each page then has its own PHP file with a class that extends the Action class. Each page, known as an action, should mimic the Action class by implementing a method called 'launch'.

A variety of utility classes exist in the web/sys directory. For example, the SOLR.php file allows you to make use of the underlying Solr Data Repository. For more details on the available tools, see the System Classes page.

Your module needs to make use of Global Variables to access the presentation layer and configuration file; see the linked page for more details on available globals and how to access them.

Here is a shell for an action class:

<?php
require_once 'Action.php';
class MyAction extends Action
{
    function launch()
    {
        global $interface;
        global $configArray;
 
        $interface->setPageTitle('My Action');
        $interface->setTemplate('myaction.tpl');
 
        // Do Something Here
 
        $interface->display('layout.tpl');
    }
}
?>

Front End Presentation

In order to display the output of your new module, you also have to create a Smarty template file in the web/interface/themes/[theme]/[module_name]/ directory. The template's filename is the value passed to setTemplate method of the $interface global. For example, myaction.tpl from the example above could look like this:

<p>Hello, world!</p>

See the User Interface Customization page for more details on building templates and customizing VuFind's look and feel.

legacy/vufind_1.x_developer_manual/building_a_module.1449865709.txt.gz · Last modified: 2015/12/11 20:28 by demiankatz