Several of Joomla!'s core components allow you to order records in a list by clicking on arrows in the Ordering column. We can accomplish the same by using Joomla!'s JPagination
class, and the move()
member function of JTable
. Before doing this, we should start displaying the records in the correct order. Make the highlighted adjustment to the query in the /administrator/components/com_critic/views/critics/view.html.php
file:
$db =& JFactory::getDBO();
$db->setQuery('SELECT * FROM #__critic ORDER BY ordering');
$rows = $db->loadObjectList();
Save the file, and then reload /administrator/index.php?option=com_critic
in the browser. Your screen should now have the records sorted by the Ordering column and should look similar to the following:
Next, we need to bring in the JPagination
class that will help us generate the up and down arrows on the list screen. Again, in the views/critics/view.html.php
file, add the following highlighted code:
$rows = $db->loadObjectList...