Backend pagination problem in joomla1.7

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alimziyan
    New Member
    • Jul 2011
    • 1

    Backend pagination problem in joomla1.7

    Hi,
    I am new to joomla component development.Now i am creating a simple image gallery.I have created it sucessfully in joomla1.6. But a small pagination problem while using it in joomla 1.7.The backend pagination is not working. I am using the tutorial "http://blog.opensource network.eu/tutorials/guru/mvc-workflow-with-jpagination".i am including the code here.
    In model :
    Code:
    <?php 
    defined('_JEXEC') or die( 'Restricted access' ); 
    jimport('joomla.application.component.model'); 
    
    class ComponentnameModelModelname extends JModel 
    { 
        var $_data = null;
        var $_total = null;
        var $_pagination = null;
    
        function __construct() 
        {
        	  	parent::__construct(); 
    			$application = JFactory::getApplication() ; 
    
        		$config = JFactory::getConfig() ; 
    
        		$limitstart = JRequest::getInt( 'limitstart', 0 );
      			//  $limit = $application->getUserStateFromRequest( 'global.list.limit', 
           			// 'limit', $config->getValue('config.list_limit'), 'int' );        
    			$limit = 1;
        		$this->setState('limitstart', $limitstart); 
        		$this->setState('limit', $limit); 
        	
        }
           
        function _loadData() 
        {
           	if (empty($this->_data) && empty($this->_total)) 
        	{ 
    			
    			$album = JRequest::getVar( 'album'); 
    			
           		$query = "SELECT * FROM #__databasename WHERE albumname='".$album."'";
            	$this->_db->setQuery($query); 
    
            	$this->_data = $this->_db->loadObjectList(); 
            	$this->_total = count( $this->_data ) ; 
    
        	} 
    
        	return $this->_data ; 
           	
        }
        
        function getData() 
        {
        	$this->_loadData() ; 
        $album = JRequest::getVar( 'album'); 
       
        	$limitstart = $this->getState('limitstart');
        	$limit = $this->getState('limit');
    
           return array_slice( $this->_data, $limitstart,  $limit); 
        }
        
        function getTotal() 
        {
           return $this->_total; 
           	
        }
        
        function getPagination() 
        {
           	 $this->_loadData() ;
    
        	if (empty($this->_pagination)) 
        	{ 
            	jimport('joomla.html.pagination'); 
    
           	 	$limitstart = $this->getState('limitstart');
            	$limit = $this->getState('limit');
           		$total = $this->getTotal();
    	
    			$this->_pagination = new JPagination( $total, $limitstart,$limit); 
        	} 
    
        	return $this->_pagination; 
           	
         } 
    }
    ?>
    In views/photos/tmpl/default.php
    Code:
    <?php
    defined('_JEXEC') or die( 'Restricted access' );
    $host = JURI::root();
    jimport('joomla.html.pagination');
    ?>
    [B]<form name="adminForm" method="post">[/B]
    	<div class = "photo">
    		<img src="<?php echo $host?>images/<?php echo $item->image;?>" height = "300" width = "300" alt = "no image" />
             </div>
    	<div id="photopagination">
    		<?php  echo $this->pagination->getPageslinks();?>
    	</div>
    	[B]<div style="display:none">
    		<?php  echo $this->pagination->getListFooter(); ?>
    	</div>[/B]
    </form>
    I am using a form named admin form in template file.When i add the getListFooter function only,pagination is working in backend.Is ant modification needs to be done in joomla 1.7 for working this???
  • vaishali123
    New Member
    • Nov 2011
    • 1

    #2
    Try replacing
    <form name="adminForm " method="post">
    with
    <form name="adminForm " method="post" id='adminForm'>
    in your views/photos/tmpl/default.php file..
    Hope it works for you!!

    Comment

    Working...