- HTML Admin-Manual
- PDF Admin-Manual
- HTML ITSM-Manual
- PDF ITSM-Manual
- HTML Developer-Manual
- PDF Developer-Manual
- HTML Developer-API
7.4. Frontend Modules
Frontend Modules are located under "$OTRS_HOME/Kernel/Modules/*.pm". There are two public functions in there - new() and run() - which are accessed from the Frontend Handle (e. g. index.pl). "new()" is used to create a frontend module object. The Frontend Handle provides the used frontend module with the basic framework object. These are, for example: ParamObject (to get formular params), DBObject (to use existing database connects), LayoutObject (to use templates and other html layout functions), ConfigObject (to access config settings), LogObject (to use the framework log system), UserObject (to get the user functions from the current user), GroupObject (to get the group functions).
For more information on core modules see http://dev.otrs.org/
Format:
# --
# Kernel/Modules/AgentTest.pm - message of the day
# Copyright (C) 2005 Hans Mueller mail@example.com
# --
# $Id: module-format.xml,v 1.17.4.3 2007/10/17 06:25:49 tr Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --
package Kernel::Modules::AgentTest;
use strict;
# --
sub new {
my $Type = shift;
my %Param = @_;
[...]
return $Self;
}
# --
sub Run {
my $Self = shift;
my %Param = @_;
[...]
# ---------------------------------------------------------- #
# add a new object (Note: dtl text 'New')
# ---------------------------------------------------------- #
if ($Self->{Subaction} eq 'Add') {
my $Output = '';
my %Frontend = ();
[...]
# add add block
$Self->{LayoutObject}->Block(
Name => 'Add',
Data => {%Param, %Frontend},
);
# build output
$Output .= $Self->{LayoutObject}->Header(Area => 'Agent', Title => "Test");
$Output .= $Self->{LayoutObject}->NavigationBar();
$Output .= $Self->{LayoutObject}->Output(
Data => {%Param, %Frontend},
TemplateFile => 'AgentTest',
);
$Output .= $Self->{LayoutObject}->Footer();
return $Output;
}
# ---------------------------------------------------------- #
# show overview screen
# ---------------------------------------------------------- #
elsif ($Self->{Subaction} eq 'Overview') {
# add overview block
$Self->{LayoutObject}->Block(
Name => 'Overview',
Data => {%Param, %Frontend},
);
# build output
$Output .= $Self->{LayoutObject}->Header(Area => 'Agent', Title => "Test");
$Output .= $Self->{LayoutObject}->NavigationBar();
$Output .= $Self->{LayoutObject}->Output(
Data => {%Param, %Frontend},
TemplateFile => 'AgentTest',
);
$Output .= $Self->{LayoutObject}->Footer();
return $Output;
}
# ---------------------------------------------------------- #
# show error screen
# ---------------------------------------------------------- #
return $Self->{LayoutObject}->ErrorScreen(Message => "Invalid Subaction process!");
}
# --
1;
You also need a module registration for frontend modules. Define read only groups with the "GroupRo" and read/write groups with the 'Group' param (see table below for details). You can define navigation bar icons via the "NavBar'"param, too (see table below for details).
[Kernel/Config.pm]
$Self->{'Frontend::Module'}->{'AgentTest'} = {
Group => ['admin'],
GroupRo => ['test', 'admin'],
Description => 'A test Module',
NavBarName => 'Ticket',
NavBar => [
{
Description => 'Test Module',
Name => 'Test',
Image => 'stats.png',
Link => 'Action=AgentTest',
NavBar => 'Ticket',
Prio => 85,
},
],
};
You can access this frontend module via http (browse) with the Action param = Module or over the navigation bar.
http://localhost/otrs/index.pl?Action=AgentTest
Description of Frontend::Module options:
| Key | Description |
|---|---|
| Group | An ARRAY reference of rw groups of this module. |
| GroupRo | An ARRAY reference of ro groups of this module. |
| Description | Module description, just for internal use - not shown in the user interface. |
| NavBarName | NavBar context name of this module. |
Description of NavBar (icon points) options:
| Key | Description |
|---|---|
| Description | The description of the icon which is shown in the navbar after the curser is pointed on it. |
| Name | The icon name shown in the navbar. |
| Image | The icon image shown in the navbar. |
| Link | The link behind the icon in the navbar. |
| NavBar | Only shown this icon in this NavBar context. |
| Prio | Sort prio of the icon in the navbar. |

