dongxidui1227 2013-06-17 17:38
浏览 26
已采纳

的Joomla! 2.5不读取默认布局

Problem I am having is that making a new component I cannot seem to get joomla to read the default layout file. This is happening in both the admin and site side of the component. Comparing it to another component I have created that works I can see no logical reason for it as both components work in the same environment.

I know that since the site and admin use the same methods, fixing it in one should fix it in the other. So here is the site side of things.

first the view.html.php

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla view library
jimport('joomla.application.component.view');

class ComponentViewComponent extends JView{
    function display($tpl = null){
        parent::display($tpl);
    }
}


?>

Then the tmpl/default.php

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted Access');


// load tooltip behavior
JHtml::_('behavior.tooltip');


?>
hello

As you can see it is barebones still, but when ever I try to access it on the site or admin it will say "500: Layout default not found".

I have spent over n hour now trying to find out where I went wrong that might of caused this.

Although I doubt it will matter here is the model/controller/constructor

component.php (named differently then actual component)

<?php
//No direct access to this file
defined('_JEXEC') or die ('Restricted access');

// import joomla controller library
jimport('joomla.application.component.controller');

// Get an instance of the controller prefixed by GoTireReviews
$controller = JController::getInstance('Component');

// Perform the Request task
$input = JFactory::getApplication()->input;
$controller->execute($input->getCmd('task'));

// Redirect if set by the controller
$controller->redirect();

?>

models/component.php

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla modelitem library
jimport('joomla.application.component.modelitem');

class ComponentModelComponent extends JModelItem{

}


?>

controller.php

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla controller library
jimport('joomla.application.component.controller');

class ComponentController extends JController{

}


?>

I may be blind and missing something, but with the amount of time I spent so far attempting minor tweaks it seems that restarting from scratch might be a less time consuming approach.

Also another note the component is not named "component" but I used it to make this example more readable.

EDIT:

Found out the reason, it is because I used the word review in the name of the component. Doing that tricks joomla's view methods and causes the error. (I changed the name of the component for the purpose of this without thinking that it may cause that)

  • 写回答

1条回答 默认 最新

  • douluolan9101 2013-06-17 22:53
    关注

    In Joomla 2.5 it names its MVC instances using a prefix, then the method then the name.

    Like so:

    ComponentViewComponent or ComponentViewDefault

    To do this it looks for the word view in the string of the class name. So if you name it like so you will cause an error:

    ComponentReviewViewComponentReview

    In this case you might feel naming it review would cause no harm, however it does contain view inside. The error Joomla gives does not point you in the right direction normally either.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化