amilaishere
amilaishere

Reputation: 408

Joomla custom component not found 404 error

I created joomla custom component and installed without any errors. But when I'm trying to access the component it throws me 404 , component not found error.

name of the component is com_eta. I used administrator/index.php?option=com_eta for access the back end component.

I googled , and check source code several times but I couldn't figure out whats wrong with my code. I also check the database by searching for com_eta. I couldn't find any unusual thing.

here is my xml code and php code for backend component file. if anyone can point me to right direction, It's highly appreciated.

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();

Upvotes: 1

Views: 5130

Answers (1)

amilaishere
amilaishere

Reputation: 408

mohsenkw gave the correct answer. 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.

Upvotes: 2

Related Questions