about PAGINATION in the back-end

Locked
c1000mg
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Aug 24, 2008 5:59 am

about PAGINATION in the back-end

Post by c1000mg » Mon Aug 25, 2008 12:34 am

I was wondering if anyone can help me with my problem, I'm trying to make my own component in the back-end... and I want to ad pagination and eventually add some filters to my list and I followed the instruction step by step from the book "Learning Joomla Extencions" but it doesn't work it just shows all the records and at the bottom shows the pagination but every page shows all the records even if I change the amount of records to display and goes back to 20 records and I notice that is using the data to build the pagination but it wont show just the limit per page... please HELP

this is the code in my controller.php

Code: Select all

function showFishList()
{
  global $option, $mainframe;
  $limit = JRequest::getVar('limit', $mainframe->getCfg('list_limit'));
  $limitstart = JRequest::getVar('limitstart', 0);
  $db =& JFactory::getDBO();
  $query = "SELECT count(*) FROM #__fish_description";
  $db->setQuery( $query );
  $total = $db->loadResult();
  $query = "SELECT * FROM #__fish_description";
  $db->setQuery( $query, $limitstart, $limit );
  $db->setQuery( $query );
  $rows = $db->loadObjectList();
  if ($db->getErrorNum()) {
      echo $db->stderr();
    return false;
}
jimport('joomla.html.pagination');
$pageNav = new JPagination($total, $limitstart, $limit);
HTML_fishsearch::showFishList( $option, $rows, $pageNav );
}
and this is the html code:

Code: Select all

function showFishList( $option, &$rows, &$pageNav )
{
  ?>
  <form action="index.php" method="post" name="adminForm">
  <table class="adminlist">
<thead>
       <tr>
         <th width="20">
            <input type="checkbox" name="toggle"
                 value="" onclick="checkAll(<?php echo
                 count( $rows ); ?>);" />
         </th>
         <th align="center" valign="middle"><img src="components/com_fishsearch/images/googlesearch.gif" alt="" width="18" height="18" title="Feeding" /></th>
         <th>Scientific Name</th>
         <th>Common Name</th>
         <th>Discover By</th>
         <th>GeoLocation</th>
         <th>Ecosystem</th>
         <th width="30">F</th>
         <th width="30">D</th>
         <th width="30">C</th>
         <th width="30">S</th>
         <th width="5%" nowrap="nowrap">Status</th>
       </tr>
     </thead>
         <?php
		 jimport('joomla.filter.output');
    $k = 0;
    for ($i=0, $n=count( $rows ); $i < $n; $i++)
    {
       $row = &$rows[$i];
       $checked = JHTML::_('grid.id', $i, $row->FishID );
       $published = JHTML::_('grid.published', $row, $i );
	   $link = 'index.php?option=' . $option . '&task=edit&cid[]='. $row->FishID ; 
		?>
       <tr class="<?php echo "row$k"; ?>">
          <td>
            <?php echo $checked; ?>
          </td>
          <td align="center" valign="middle">
          <img src="components/com_fishsearch/images/googlesearch.gif" alt="" width="18" height="18" title="Search Scientific Name Google" /></td>
         <td>
          <a href="<?php echo $link; ?>"><?php echo $row->ScientificName; ?></a>
          </td>
          <td>
            <?php echo $row->CommonName; ?>
          </td>
          <td>
            <?php echo '('.$row->discoveredby.')'; ?>
          </td>
          <td>
            <?php echo $row->GeoLocation; ?>
          </td>
          <td>
            <?php echo $row->MainEcosystem; ?>
          </td>
          <td align="center"><img src="../../images/FishSearch/icons/icon-food<?php echo $row->FeedingID; ?>.gif" width="20" height="20" title="Feeding" /></td>
        <td align="center"><img src="../../images/FishSearch/icons/icon-dif<?php echo $row->DifficultyID; ?>.gif" width="20" height="20" title="Difficulty"/></td>
        <td align="center"><img src="../../images/FishSearch/icons/icon-comp<?php echo $row->CompatibilityID; ?>.gif" width="20" height="20" title="Compatibility"/></td>
        <td align="center"><img src="../../images/FishSearch/icons/icon-strat<?php echo $row->StratumID; ?>.gif" width="20" height="20" title="Stratum"/></td>
<td align="center">
            <?php echo $published;?>
          </td>
       </tr>
       <?php
       $k = 1 - $k;
    }
    ?>
<tfoot>
<td colspan="12"><?php echo $pageNav->getListFooter(); ?></td>
</tfoot>
  </table>
  <input type="hidden" name="option" value="<?php echo $option;?>" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="boxchecked" value="0" />
  </form>
  <?php
}

thank you all

 
c1000mg
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Aug 24, 2008 5:59 am

Re: about PAGINATION in the back-end

Post by c1000mg » Mon Aug 25, 2008 1:44 am

It's amazing that I figured out.... but was a typing error!!! I just re-type the text and it works...

I actually ran in another problem that is How can I make the limit and the page to stay after I save or edit anything in the back end?? I mean after I select the limit i say 5 in the list and I go to edit and save or apply I loose where I was in the list... it goes to the first page and set to 20 (default view of the list)

Thank you

 

Locked

Return to “Joombie Coding Q/A”