Joomla 2.5 displaying data /multiple rows in view -
i'm new joomla development. after having managed directly list database multiple rows directly conttroller, i'm trying display using views, have error message :
controller :
function display($cachable = false, $urlparams = false) { // affichage de la liste des tournois $db=jfactory::getdbo(); $sql="select * #__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);
in view :
function display($tpl = null) { // data model $items = $this->get('items'); // check errors. if (count($errors = $this->get('errors'))) { jerror::raiseerror(500, implode('<br />', $errors)); return false; } // assign data view $this->items = $items; // set toolbar $this->addtoolbar(); // display template parent::display($tpl); }
in default 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 $i => $item) { //$row=$rows[$i]?> <tr> <th><? echo $item->tournois_id?></th> <th><? echo $item->tournois_title?></th> </tr> <?}?> </table> </form>
Comments
Post a Comment