【问题标题】:Joomla component Development: Invalid controller: name='', format=''Joomla 组件开发:无效的控制器:name='',format=''
【发布时间】:2023-03-05 12:31:01
【问题描述】:

我正在尝试从here 开发组件。我在管理部分收到错误

500 - 发生错误。

无效的控制器:name='', format=''

如何调试这个?我什至不知道什么代码与发布相关。

文件:admin/controller.php

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

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

class TestimonialsController extends JController {
    function display($cachable = false) {
        // set default view if not set
        JRequest::setVar('view', JRequest::getCmd('view', 'Testimonials'));

        // call parent behavior
        parent::display($cachable);
    }
}

文件:admin/testimonials.php

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

jimport('joomla.application.component.controller');
$controller = JController::getInstance('Testimonials');
$controller->execute(JRequest::getCmd('task'));
$controller->redirect();

文件:admin/views/testimonials/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 TestimonialsViewTestimonials extends JView {
    function display($tpl = null) {
            $items = $this -> get("Items");
            $pagination = $this -> get("Pagination");

            //Check for errors
            if (count($errors = $this->get('Errors'))) 
            {
                JError::raiseError(500, implode('<br />', $errors));
                return false;
            }

            // Assign data to the view
            $this -> items = $items;
            $this -> pagination = $pagination;

            // Display the template
            parent::display($tpl);

    }
}

【问题讨论】:

  • 你能把admin/testimonials.php文件也放上来吗?
  • @GeorgeWilson,我更新了我的帖子。非常感谢您帮助我。
  • @mrN:你是怎么访问这个组件的?或者你什么时候收到这个错误的?
  • @Irfan,当我通过管理菜单访问或浏览到administrator/index.php?option=com_testimonials
  • @mrN 在 admin/views/testimonials/view.html.php 你有一些类似的东西...... class TestomonialsViewTestomonials extends JView ?另外我假设在 admin/controller.php 你包括

标签: joomla components


【解决方案1】:

@mrN:xml 文件呢?您可以验证部分 有所有档案。

文件丢失时的错误 500 示例:

<!-- file testimonials.xml -->
<!-- ERROR 500 because <em>admin/controller.php</em> is not installed -->
...
<administration>
    <!-- Administration Menu Section -->
    <menu>Testimonials</menu>
    <!-- Administration Main File Copy Section -->
    <!-- Note the folder attribute: This attribute describes the folder
         to copy FROM in the package to install therefore files copied
         in this section are copied from /admin/ in the package -->
    <files folder="admin">
    <!-- Admin Main File Copy Section -->
        <filename>index.html</filename>
        <filename>testimonials.php</filename>
        <!-- SQL files section -->
        <folder>sql</folder>
    </files>
</administration>
...

【讨论】:

  • 奇怪的是我忘了检查 XML 文件。
猜你喜欢
  • 1970-01-01
  • 2014-09-19
  • 2013-04-15
  • 2016-12-17
  • 2013-05-18
  • 2014-10-17
  • 1970-01-01
  • 2012-11-18
  • 1970-01-01
相关资源
最近更新 更多