Hello World im Kundenfrontend?

English! place to talk about development, programming and coding
Post Reply
Anna89
Znuny newbie
Posts: 8
Joined: 04 Oct 2009, 18:12
Znuny Version: 2.3.4

Hello World im Kundenfrontend?

Post by Anna89 »

Hallo,

ich möchte mich ein wenig in die Modul-Entwicklung einarbeiten und bin schon bei den ersten Schritten gescheitert. Vielleicht könnt Ihr mir weiterhelfen?
Als erstes kleines Projekt wollte ich ein HelloWorld-Modul bauen, das analog zu dem Admin-Frontend-Modul in der Doku funktioniert, aber im Unterschied dazu im Kundenfrontend angezeigt werden soll und nur für eine bestimmte Gruppe freigeschaltet sein soll. Was muss ich an der xml und evtl. am Frontend-Modul ändern, sodass das Modul korrekt eingebunden wird?

Vielen Dank für Eure Hilfe.
Grüße von Anna

XML (Zitat aus der Doku):

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<otrs_config version="1.0" init="Application">
        <ConfigItem Name="Frontend::Module###AgentHelloWorld" Required="1" Valid="1">
        <Description Lang="en">FrontendModuleRegistration for HelloWorld modul.</Description>
        <Description Lang="de">FrontendModulRegistration für das HelloWorld Modul.</Description>
        <Group>HelloWorld</Group>
        <SubGroup>AgentFrontendModuleRegistration</SubGroup>
        <Setting>
            <FrontendModuleReg>
                <Title>HelloWorld</Title>
                <Group>users</Group>
                <Description>HelloWorld</Description>
                <NavBarName>HelloWorld</NavBarName>
                <NavBar>
                    <Description>HelloWorld</Description>
                    <Name>HelloWorld</Name>
                    <Image>overview.png</Image>
                    <Link>Action=AgentHelloWorld</Link>
                    <NavBar>HelloWorld</NavBar>
                    <Type>Menu</Type>
                    <Prio>8400</Prio>
                    <Block>ItemArea</Block>
                </NavBar>
            </FrontendModuleReg>
        </Setting>
    </ConfigItem>
</otrs_config>
Frontend-Modul für den Admin-Bereich (Zitat aus der Doku):

Code: Select all

# --
# Kernel/Modules/AgentHelloWorld.pm - frontend modul
# Copyright (C) 2001-2005 Martin Edenhofer <martin+code@otrs.org>
# --
# $Id: writing-otrs-application.xml,v 1.11 2006/06/07 14:10:34 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::AgentHelloWorld;

use strict;
use Kernel::System::HelloWorld;

sub new {
    my $Type = shift;
    my %Param = @_;

    # allocate new hash for object
    my $Self = {};
    bless ($Self, $Type);
    # get common objects
    foreach (keys %Param) {
        $Self->{$_} = $Param{$_};
    }
    # check needed Opjects
    foreach (qw(ParamObject DBObject ModuleReg LogObject ConfigObject)) {
        $Self->{LayoutObject}->FatalError(Message => "Got no $_!") if (!$Self->{$_});
    }
    # create needed objects
    $Self->{HelloWorldObject} = Kernel::System::HelloWorld->new(%Param);

    return $Self;
}
# --
sub Run {
    my $Self        = shift;
    my %Param       = @_;
    my $Output      = '';
    my %Data = ();

    $Data{HelloWorldText} = $Self->{HelloWorldObject}->GetHelloWorldText();
    # build output
    $Output .= $Self->{LayoutObject}->Header(Title => "HelloWorld");
    $Output .= $Self->{LayoutObject}->NavigationBar();
    $Output .= $Self->{LayoutObject}->Output(
        Data => \%Data,
        TemplateFile => 'AgentHelloWorld',
    );
    $Output .= $Self->{LayoutObject}->Footer();
    return $Output;
}
1;

Post Reply