Hi everyone I did a component for back-end in joomla 2.5, but I have problem to execute the sql query, my variable is empty so it don´t show me nothing.
I have other file and documents, but here the important for my question.
first in my controller.php I have this inside admin file
class BusquedaController extends JController
{
protected $default_view= 'restaurantes';
public function display(){
parent::display();
}
}
in my Model file I have restaurante.php
class BusquedaModelRestaurante extends JModelList{
function getListaRestaurantes(){
$db= JFactory::getDBO();
$sql= "SELECT * FROM #__restaurantes";
$db->setQuery($sql);
return $db->loadObjectList();
}
}
in my controller File I have this
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();
}
}
finally in my View File I have a tmpl file with my default.php that show a table
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
but the element reslist is empty, I don't know if I do my component well!!, someone know a tutorial or something to do a component in joomla 2.5
thanks!