6.0.0-git
2024-04-20
Last Modified 2009-02-19 by Guest

Introduction

by Torben Dannhauer

The process of populating the new module with content/functionality is fairly straight forward and after learning how the Horde API' s work, you should be able to produce new modules in a minimum amount of time.

Jan Schneider talked about this at FOSDEM 2005. You can find his slides at http://www.horde.org/papers/fosdem2005/.

The new module's functionality could by separated in the following aspects:

  • Menus
    • Calling-procedure at entering the application
    • Permissions
    • All Content-Pages which are accessible through on oh the menus
    • Services offered to external modules

Usually it is useful to analyse another hordemodule to learn how this work. I analysed Kronolith and it helped me a lot.

Obviously it is necessary to know the provided horde API zu write a horde module. Because a beginner (and this tutorial is adressed to them) has no clue about it, it is very usefull to read the package-documentation at http://dev.horde.org/api/framework/.

Menus

In Horde there are two standard menus: The top menu an the side menu.

ToDo: Add links to Wikipages describing menus in detail.

Top Menu

The top menu is devided in to 4 sections:

  • left: menuitems provided by this module: see below
    • mid left: menuitems added manually: see below
    • mid right: menuitems added in the administrator's module setup
    • right: menuitems provided by horde as default

left

the menuitmes this module intentionally provide are located in the file <module>/lib/Module.php in the function ::getMenu()

Add Items like this:

 

 $menu->add(Horde::applicationUrl('pagetoshow.php'), _("MenuItemName"), 'icon.png', $registry->getImageDir() );

mid left

Items are added in <module>/config/menu.php:


$_menu[] = array(

      'url' =>        'http://www.example.com/',

      'text' =>       'Example, Inc.',

      'icon' =>       'example.png',

      'icon_path' =>  'http://www.example.com/images/',

      'target' =>     '_blank',

      'onclick' =>    ''

  );

Side Menu

Calling procedure at entering the application

If a module is entered via the side-menu, usualy the url to the module-folder was provided. The link ist http://<myHordeInstallation>/<mymodule> without any file suffix. So the calling procedure starts by executing the index.php on the webserver.

Procedure:

  • Executing index.php: initialzing, load configfiles and load the page which should be displayed at the beginning (e.g. in Skeleton: list.php).
    • list.php calls >module>/lib/base.php to initialize the module and then proceeds with its content.
    • now lists.php is displayed. By Clicking on any menuitem another contentpage as list.php (but of course also list.php again) could be displayed (->executed).

Permissions

The module's permissiontree which includes the logical structure of all permissions available in this module is defined in <module>/lib/api.php

Further information about permissions is available at http://wiki.horde.org/Doc/Dev/PermsPackage

Backenddriver

The easiest way to learn writing a backend-Driver for managing the data your first module works with is to extend the Skeletons SQL-Driver.

  • Edit config/conf.xml: Add the databset tables you want be configurable. Attention: one databaset table with name "table" MUST exist! Example :


<configstring name="table2" desc="My Database">mymodule_table which is needed</configstring>

  • go to your horde configuration, configurate your module to get your conf.php written with your new configs.
    • ...to proceed

Content-Page

The basic procedure to create Content-Pages is:

  • create .inc files that display the elements on the screen
    • create any php files needed to fill in forms

It is a good point to start a contentpage by copying the Skeleton's list.php

All viewable pages ar located in the module's root-folder. All businesslogic (classes etc,) are located in separate files in <module>/lib.

Layout

To move your businesslogic-variabes to a html-layout, the Horde_Templates-Package is usefull. You can include templates with code tags, and Horde will replace these tags with your variable-content, if the tags and the variables are associated via template->setVariable(...); For further information read about this package wiki.horde.org : /Doc/Dev/TemplatePackage

If a submenu on the content page ist needed (likle in turba), it can be generated via <div class="control nowrap"> ..menu..</div>

Scripts

If any scripts are needed for layout like striped.js für alternating rowcolors, add these scrippts via Horde::addScriptFile('<script.js', 'ownerapplication_where_to_search: e.g. horde', true ). True means that the script should be included via relativ path.

Services

Misc