我第一次创建了一个新组件。它的后端功能都运行良好。现在我想在前端展示。我创建了一个新的菜单项并选择了这个新的组件,但是当我点击我的菜单错误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;
}
}
?>
如果需要任何澄清,请告诉我。
答案 0 :(得分:1)
在 views / tenders / view.html.php 中将类从TendersViewTender
重命名为TendersViewTenders
您需要在 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();