Joomla Pagination

Webgau

Mitglied
Servus,

ich bin gerade dabei mir eine Komponente zusammen zustricken und habe ei Problem mit der Pagination,

Als erstes mal mein Code:

Das Model:
PHP:
<?php
/**
* @package helloworld02
* @version 1.1
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software and parts of it may contain or be derived from the
* GNU General Public License or other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

jimport( 'joomla.application.component.model' );

/**
 * @package Joomla
 * @subpackage Config
 */
class tvModeltv extends JModel
{
	/**
	 * helloworld data
	 *
	 * @var array
	 */
	var $_data = null;
	
	var $_pagination = null;


	/**
	 * table_prefix - table prefix for all component table
	 * 
	 * @var string
	 */
	var $_table_prefix = null;
	

  function __construct()
  {
        parent::__construct();
		
		$this->_table_prefix = '#__tv_';

        global $mainframe, $option;

        // Get pagination request variables
        $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 10);
        $limitstart = $mainframe->getUserStateFromRequest($option.'.limitstart', 'limitstart', 0, 0);

        // In case limit has been changed, adjust it
        $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);

        $this->setState('limit', $limit);
        $this->setState('limitstart', $limitstart);
  }


  function getData() 
  {
        // if data hasn't already been obtained, load it
        if (empty($this->_data)) {
            $query = 'select * from '.$this->_table_prefix.'tv'.$this->_buildQuery();
;
            $this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));        
        }
        return $this->_data;
  }
  
  function getTotal()
  {
        // Load the content if it doesn't already exist
        if (empty($this->_total)) {
            $query = 'select * from '.$this->_table_prefix.'tv'.$this->_buildQuery();
;
            $this->_total = $this->_getListCount($query); 
        }
        return $this->_total;
  }

function getPagination()
  {
        // Load the content if it doesn't already exist
        if (empty($this->_pagination)) {
            jimport('joomla.html.pagination');
            $this->_pagination = new JPagination($this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
        }
        return $this->_pagination;
  }


}
?>
Der Wiev
PHP:
<?php
/**
* @package helloworld02
* @version 1.1
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software and parts of it may contain or be derived from the
* GNU General Public License or other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/


// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

//DEVNOTE: import VIEW object class
jimport( 'joomla.application.component.view' );

/**
 [controller]View[controller]
 */
 
class tvViewtv extends JView
{
	/**
	 * Custom Constructor
	 */
	function __construct( $config = array())
	{
	 /** set up global variable for sorting etc.
	  * $context is used in VIEW and in MODEL
	  **/	  
	 
 	 parent::__construct( $config );
	}
  
	 
	/**
	 * Display the view
	 * take data from MODEL and put them into	
	 * reference variables
	 * 
	 * Go to MODEL, execute Method getData and
	 * result save into reference variable $items	 	 	 
	 * $items		= & $this->get( 'Data');
	 * - getData gets the country list from DB	 
	 *	  
	 * variable filter_order specifies what is the order by column
	 * variable filter_order_Dir sepcifies if the ordering is [ascending,descending]	 	 	 	  
	 */
    
	function display($tpl = null)
	{
		//DEVNOTE: set document title
		$document = & JFactory::getDocument();		
		$document->setTitle( JText::_('HELLOWORLD') );
  
          // Get data from the model
        $items =& $this->get('Data');    
        $pagination =& $this->get('Pagination');

        // push data into the template
        $this->assignRef('items', $items);   
        $this->assignRef('pagination', $pagination);
		
    //DEVNOTE:save a reference into view	
  	$this->assignRef('items',				$items); 		
		//DEVNOTE:call parent display
    parent::display($tpl);
  }
  }
?>

und die default:
PHP:
<?php 
/**
* @package helloworld02
* @version 1.1
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software and parts of it may contain or be derived from the
* GNU General Public License or other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Restricted access'); 
?>
<table width='100%' border='0' cellspacing='3' cellpadding='3'><?php
for ($i=0, $n=count( $this->items ); $i < $n; $i++)
 {
   $row = &$this->items[$i]; ?>		

		<tr>
        	<td colspan='3' valign='top'><img src="/components/com_tv/images/tv.png" alt="TV-Tipp" name="TV-Tipp" />&nbsp;<strong><?php echo $row->title; ?></strong><hr /></td>
        </tr>
  		<tr>
    		<td valign='top' width='15%'><strong>Datum:</strong><br /><div style="font-size:0.9em;"><?php $date = new DateTime($row->adate); echo $date->format("d.m.Y"); echo " um ".$date->format("H:i")." Uhr"; ?></div></td>
    		<td valign='top' width='10%'><strong>Sender:</strong><br /><div style="font-size:0.9em;"><?php echo $row->sender; ?></div></td>
   			<td valign='top'><?php echo $row->description; ?></td>
  		</tr>
        		<tr>
        	<td colspan='3' valign='top'><p>&nbsp;</p></td>
        </tr>
<?php }
?>
</table>  
<form action="<?php echo JRoute::_($this->slink);?>" method="post" name="adminForm" >
<div class="pagination">
	<?php echo $this->pagination->getPagesLinks(); ?>
</div>
</form>

Die blätter Funktion als "Start 123 Ende" Funktioniert zwar, allerdings kann ich die Seite eins nachdem ich anfange mit dem blättern nicht mehr anklicken...

hier mal die komponente zur verdeutlichung: http://feuerwehr-suchmaschine.de/tv-tipps.html.

Vielen Dank erstmal
Grüße mirko
 
Zurück