我创建了joomla自定义组件并安装没有任何错误。但是当我试图访问该组件时,它会抛出404,组件未找到错误。
组件的名称是com_eta。 我使用administrator / index.php?option = com_eta来访问后端组件。
我用谷歌搜索,并多次查看源代码,但我无法弄清楚我的代码是什么问题。我还通过搜索com_eta来检查数据库。我找不到任何不寻常的东西。
这是我的后端组件文件的xml代码和php代码。如果有人能指出我正确的方向,我们非常感激。
travels.xml
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.0" type="component" method="upgrade">
<name>com_eta</name>
<creationDate>Dec 2013</creationDate>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<version>1.0</version>
<description>CUSTOM JOOMLA COMPONENT</description>
<administration>
<menu>Travels </menu>
<files folder="admin">
<filename>travels.php</filename>
<filename>index.html</filename>
<folder>controllers</folder>
<folder>assets</folder>
<folder>helpers</folder>
<folder>tables</folder>
<folder>models</folder>
<folder>views</folder>
</files>
</administration>
<files folder="site">
<filename>travels.php</filename>
<filename>index.html</filename>
<folder>controllers</folder>
<folder>views</folder>
</files>
</extension>
travels.php
<?php
//give no direct access
defined('_JEXEC') or die('Restricted access');
define("ETA_COMPONENT", "com_eta");
define("ETA_COMPONENT_NAME", "Travel Agency");
define("ETA_COMPONENT_LINK", "index.php?option=" . ETA_COMPONENT);
if (!defined('DS'))
define('DS', DIRECTORY_SEPARATOR);
//check weather user can access the component
if (!JFactory::getUser()->authorise('core.manage', 'com_eta')) {
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
//load the helper classes we need all the time
require JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'general_helper.php';
//set default controller to configuratrion
$controller = JRequest::getVar('controller', 'admindata');
//get the task
$task = JRequest::getVar('task', 'display');
//assign controller class and load it
$classname = 'TravelsController' . $controller;
//convert task name and controllr name to lower case
$controllerName = strtolower($controller);
$taskName = strtolower($task);
//load the controller file
require_once JPATH_COMPONENT . DS . 'controllers' . DS . $controller . 'controller.php';
//excute the controller
$controller = new $classname;
$controller->execute($task);
$controller->redirect();
答案 0 :(得分:2)