大家好,我在 joomla 2.5 中为后端做了一个组件,但是我在执行 sql 查询时遇到问题,我的变量是空的,所以它什么都不显示。
我还有其他文件和文件,但这里对我的问题很重要。
首先在我的controller.php 我有这个里面的管理文件
class BusquedaController extends JController
{
protected $default_view= 'restaurantes';
public function display(){
parent::display();
}
}
在我的模型文件中,我有 restaurante.php
class BusquedaModelRestaurante extends JModelList{
function getListaRestaurantes(){
$db= JFactory::getDBO();
$sql= "SELECT * FROM #__restaurantes";
$db->setQuery($sql);
return $db->loadObjectList();
}
}
在我的控制器文件中我有这个
class BusquedaControllerRestaurantes extends JControllerAdmin
{
public function getModel($name = 'Restaurante', $prefix = 'BusquedaModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
function listado(){
$firephp->log('hola');
$view=& $this->getView('restaurantes', 'html');
$model= $this->getModel("restaurante");
$listaMensajes= $model->getListaRestaurantes();
$view->assignRef('resList', $listaMensajes);
$view->display();
}
}
最后在我的视图文件中,我有一个带有 default.php 的 tmpl 文件,它显示了一个表格
foreach ($this->resList as $item):
$checked=JHTML::_('grid.id', $n, $item->id); ?>
<tr>
<td><?php echo $checked; ?></td>
<td><?php echo $item->id; ?></td>
<td><?php echo $item->nombre; ?></td>
<td><?php echo $item->direccion; ?></td>
<td><?php echo $item->telefono; ?></td>
<td><?php echo $item->web; ?></td>
<td><?php echo $item->tipo; ?></td>
<td><?php echo $item->zona; ?></td>
<td><?php echo $item->metro; ?></td>
</tr>
<?php
但是元素 reslist 是空的,我不知道我的组件做得好不好!!,有人知道在 joomla 2.5 中做组件的教程或东西
谢谢!