如何在OTRS中创建HelloWorld前端模块 安装后无法显示该如何处理
OTRS 7.0 HelloWorld模块不显示修复步骤
- 绝大多数情况是缺少导航菜单和前端模块的注册配置,按下面步骤排查即可:
1. 补全HelloWorld.xml配置
你需要在Kernel/Config/Files/HelloWorld.xml中添加前端模块和导航入口的注册规则,示例配置如下:
<?xml version="1.0" encoding="utf-8"?> <otrs_config version="2.0" init="Application"> <!-- 注册前端Agent模块 --> <Setting Name="Frontend::Module###AgentHelloWorld" Required="1" Valid="1"> <Description Translatable="1">Frontend module registration for the AgentHelloWorld interface.</Description> <Navigation>Frontend::Agent::ModuleRegistration</Navigation> <Value> <Hash> <Item Key="Group">[]</Item> <!-- 可指定可访问的用户组,空代表所有登录坐席都能访问 --> <Item Key="GroupRo">[]</Item> <Item Key="Description" Translatable="1">HelloWorld Demo Module</Item> <Item Key="Title" Translatable="1">HelloWorld</Item> <Item Key="NavBarName">HelloWorld</Item> </Hash> </Value> </Setting> <!-- 添加顶部导航栏入口 --> <Setting Name="Frontend::Navigation###AgentHelloWorld" Required="0" Valid="1"> <Description Translatable="1">Navigation bar entry for HelloWorld module.</Description> <Navigation>Frontend::Agent::Navigation</Navigation> <Value> <Array> <DefaultItem ValueType="Hash"> <Hash> <Item Key="Group">[]</Item> <Item Key="GroupRo">[]</Item> <Item Key="Description" Translatable="1">HelloWorld Demo</Item> <Item Key="Name" Translatable="1">HelloWorld</Item> <Item Key="Link">Action=AgentHelloWorld</Item> <Item Key="NavBar">HelloWorld</Item> <Item Key="Type">Menu</Item> <Item Key="Block">Top</Item> <Item Key="AccessKey">h</Item> <Item Key="Prio">8500</Item> </Hash> </DefaultItem> </Array> </Value> </Setting> </otrs_config>
2. 确认AgentHelloWorld.pm基础配置正确
模块文件开头需要包含基础的OTRS模块声明,示例如下:
package Kernel::Modules::AgentHelloWorld; use strict; use warnings; our $ObjectManagerDisabled = 1; sub new { my ( $Type, %Param ) = @_; my $Self = {%Param}; bless( $Self, $Type ); return $Self; } sub Run { my ( $Self, %Param ) = @_; my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout'); # 输出页面内容 my $Output = $LayoutObject->Header(); $Output .= $LayoutObject->NavigationBar(); $Output .= $LayoutObject->Output( TemplateFile => 'AgentHelloWorld', ); $Output .= $LayoutObject->Footer(); return $Output; } 1;
3. 重建配置并清除缓存
模块安装完成后必须手动执行OTRS缓存清理命令,才能让新配置生效:
# 切换到otrs用户 su - otrs # 重建系统配置 bin/otrs.Console.pl Maint::Config::Rebuild # 清除所有缓存 bin/otrs.Console.pl Maint::Cache::Delete
4. 验证文件权限
确保所有模块文件的属主和权限正确,默认安装路径执行如下命令:
chown -R otrs:www-data /opt/otrs chmod -R 775 /opt/otrs
完成以上操作后重新登录OTRS坐席端,即可在顶部导航栏看到HelloWorld入口。
内容的提问来源于stack exchange,提问作者Raymond
相关产品推荐
相关产品推荐

