1

我第一次创建了一个新组件。它的后端功能都运行良好。现在我想在前端展示它。我创建了一个新菜单项并选择了这个新组件,但是当我点击我的菜单错误 500 时在前端选择了View not found [name, type, prefix]: tenders, html, tendersView. 我的站点文件夹结构是:

joomla
  |components
     |com_tenders
        |controller.php
        |tenders.php
        |models
            |tenders.php
        |views
           |tenders
               |view.html.php
               |tmpl
                   |default.php

com_tenders/controller.php

<?php
defined('_JEXEC') or die('Restricted access'); 

jimport('joomla.application.component.controller');

class TendersController extends JController {

      public function display() {

        $input = JFactory::getApplication()->input;
        $input->set('view', $input->getCmd('view', 'Tenders'));
        parent::display();
      }
}
?>

意见/标书/view.html.php

<?php
defined('_JEXEC') or die('Restricted access'); 

jimport('joomla.application.component.view');

class TendersViewTenders extends JView {

    function display($tpl = null) {

    $model =& $this->getModel();
    $msg = $model->getMsg();
    $this->assignRef('msg',$msg );

    parent::display($tpl);

    }
}
?>

模型/tenders.php

<?php
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.modelitem');

class TendersModelTenders extends JModelItem {

     public function getMsg() {
           $db =& JFactory::getDBO();
           $query = "SELECT * FROM #__tenders";
           $db->setQuery( $query );
           $msg = $db->loadResult();

           return $msg;
     }
}
?>

如果需要任何澄清,请告诉我。

4

1 回答 1

1

views/tenders/view.html.php 中将类从重命名TendersViewTenderTendersViewTenders

您的com_tenders文件夹中也需要有tenders.php文件。应该是这样的:

defined( '_JEXEC' ) or die( 'Restricted access' );
require_once (JPATH_COMPONENT.DS.'controller.php');

$controller = new TendersController( );

$controller->execute( JRequest::getCmd('task'));
$controller->redirect();
于 2013-10-16T12:27:47.273 回答