简体   繁体   English

找不到Joomla自定义组件404错误

[英]Joomla custom component not found 404 error

I created joomla custom component and installed without any errors. 我创建了joomla自定义组件,并进行了正确安装。 But when I'm trying to access the component it throws me 404 , component not found error. 但是,当我尝试访问该组件时,它会抛出404,未找到组件错误。

name of the component is com_eta. 组件的名称为com_eta。 I used administrator/index.php?option=com_eta for access the back end component. 我使用Administrator / index.php?option = com_eta访问后端组件。

I googled , and check source code several times but I couldn't figure out whats wrong with my code. 我用google搜索了几次,并检查了源代码,但是我无法弄清楚我的代码有什么问题。 I also check the database by searching for com_eta. 我还通过搜索com_eta来检查数据库。 I couldn't find any unusual thing. 我找不到任何不寻常的东西。

here is my xml code and php code for backend component file. 这是后端组件文件的xml代码和php代码。 if anyone can point me to right direction, It's highly appreciated. 如果有人能指出我正确的方向,我们将不胜感激。

travels.xml 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 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();

mohsenkw gave the correct answer. mohsenkw给出了正确的答案。 Problem was the way I named the files. 问题是我命名文件的方式。 Since my component name is com_eta , travels.php and travels.xml should be names as eta.php and eta.xml. 由于我的组件名称是com_eta,travels.php和travels.xml应分别命名为eta.php和eta.xml。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM