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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog