我第一次创建了一个新组件。 它的后端功能都运行良好。 现在我想在前端展示这一点。 我创建了一个新的菜单项并选择了这个新组件,但是当我单击菜单时,在前端错误 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/控制器.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();
}
}
?>
视图/投标/视图.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);
}
}
?>
型号/招标.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;
}
}
?>
如果需要任何澄清,请告诉我。
在视图/投标/视图中.html.php将类从TendersViewTender
重命名为TendersViewTenders
您需要在com_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();