我是joomla开发的新手。在设法直接将数据库多行直接列入控制器后,我试图使用视图显示它,但我有一条错误消息:
控制器:
function display($cachable = false, $urlparams = false)
{
// Affichage de la liste des tournois
$db=JFactory::getDBO();
$sql="select * from #__tournois_tournois";
//echo $sql;
$db->setQuery($sql);
$db->query();
$items=$db->loadobjectList();
// set default view if not set
$input = JFactory::getApplication()->input;
$input->set('view', $input->getCmd('view', 'Tournois'));
// call parent behavior
parent::display($cachable);
在我看来:
function display($tpl = null)
{
// Get data from the model
$items = $this->get('Items');
// 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;
// Set the toolbar
$this->addToolBar();
// Display the template
parent::display($tpl);
}
在默认的tpl中:
<form action="<?php echo JRoute::_('index.php?option=com_tournoi&ask=edit'); ?>" method="post" name="adminTournoisForm" id="adminTournoisForm">
<table class='adminlist'>
<thead>
<tr>
<th width='1%'> </th>
<th class='title'>ID</th>
<th class='title'>Tournoi</th>
<?
foreach ($this->items as $i => $item)
{
//$row=$rows[$i]?>
<tr>
<th><? echo $item->tournois_id?></th>
<th><? echo $item->tournois_title?></th>
</tr>
<?}?>
</table>
</form>