Creating commonly-used UI elements such as lists and option buttons is automated through the use of the JHTML class. Functions within this class are designed to take an array of database results and turn them into the elements you desire. This eliminates the need for creating a loop to cycle over the results and incrementally build a string with the HTML element Joomla! does it for you.
Because there are already three critics listed in the database, they can be used to demonstrate how lists are generated through JHTML. Add this task function generateLists()
to the controller in the /components/com_critic/ critic.php
file:
function generateLists() { $db =& JFactory::getDBO(); $db->setQuery('SELECT id, name FROM #__critic ORDER BY ordering'); $rows = $db->loadObjectList(); echo '<p>' . JHTML::_('select.genericlist', $rows, 'critics', '', 'id', 'name') . '</p>'; echo '<p>' . JHTML::_('select.genericlist', $rows, 'critics', 'size...