[SOLVED] Pagination problem after searching

flyboeing 28 Nov, 2011
Hello all,

My searchform is working very well, but after searching, my pagination doesn't work anymore. I shows the first pag of results, but when I want to see page 2, it just shows all the records (the filter ain't applies anymore).

I already searched this forum for this problem and found a topic about the same problem. After reading this topic and trying it, it won't work. I am not using the standard templates (beez, purity, milkyway). I am using the template pjo_joomlaforall. This is a template I bought.

Here is the code of the pagination.php in my template folder (templates/pjo_joomlaforall/html/pagination.php):

<?php
/**
 * @version		$Id: pagination.php 7692 2007-06-08 20:41:29Z tcp $
 * @package		Joomla
 * @copyright	Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under 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');

/**
 * This is a file to add template specific chrome to pagination rendering.
 *
 * pagination_list_footer
 * 	Input variable $list is an array with offsets:
 * 		$list[limit]		: int
 * 		$list[limitstart]	: int
 * 		$list[total]		: int
 * 		$list[limitfield]	: string
 * 		$list[pagescounter]	: string
 * 		$list[pageslinks]	: string
 *
 * pagination_list_render
 * 	Input variable $list is an array with offsets:
 * 		$list[all]
 * 			[data]		: string
 * 			[active]	: boolean
 * 		$list[start]
 * 			[data]		: string
 * 			[active]	: boolean
 * 		$list[previous]
 * 			[data]		: string
 * 			[active]	: boolean
 * 		$list[next]
 * 			[data]		: string
 * 			[active]	: boolean
 * 		$list[end]
 * 			[data]		: string
 * 			[active]	: boolean
 * 		$list[pages]
 * 			[{PAGE}][data]		: string
 * 			[{PAGE}][active]	: boolean
 *
 * pagination_item_active
 * 	Input variable $item is an object with fields:
 * 		$item->base	: integer
 * 		$item->link	: string
 * 		$item->text	: string
 *
 * pagination_item_inactive
 * 	Input variable $item is an object with fields:
 * 		$item->base	: integer
 * 		$item->link	: string
 * 		$item->text	: string
 *
 * This gives template designers ultimate control over how pagination is rendered.
 *
 * NOTE: If you override pagination_item_active OR pagination_item_inactive you MUST override them both
 */

function pagination_list_footer($list)
{
	// Initialize variables
	$lang =& JFactory::getLanguage();
	$html = "<div class=\"list-footer\">\n";

	if ($lang->isRTL())
	{
		$html .= "\n<div class=\"counter\">".$list['pagescounter']."</div>";
		$html .= $list['pageslinks'];
		$html .= "\n<div class=\"limit\">".JText::_('Display Num').$list['limitfield']."</div>";
	}
	else
	{
		$html .= "\n<div class=\"limit\">".JText::_('Display Num').$list['limitfield']."</div>";
		$html .= $list['pageslinks'];
		$html .= "\n<div class=\"counter\">".$list['pagescounter']."</div>";
	}

	$html .= "\n<input type=\"hidden\" name=\"limitstart\" value=\"".$list['limitstart']."\" />";
	$html .= "\n</div>";

	return $html;
}

function pagination_list_render($list)
{
	// Initialize variables
	$lang =& JFactory::getLanguage();
	$html = "<span class=\"pagination\">";

	// Reverse output rendering for right-to-left display
	if($lang->isRTL())
	{
		$html .= '« '.$list['start']['data'];
		$html .= ' '.$list['previous']['data'];

		$list['pages'] = array_reverse( $list['pages'] );

		foreach( $list['pages'] as $page ) {
			if($page['data']['active']) {
				$html .= '<strong>';
			}

			$html .= ' '.$page['data'];

			if($page['data']['active']) {
				$html .= '</strong>';
			}
		}

		$html .= ' '.$list['next']['data'];
		$html .= ' '.$list['end']['data'];
		$html .= ' »';
	}
	else
	{
		$html .= '« '.$list['start']['data'];
		$html .= $list['previous']['data'];

		foreach( $list['pages'] as $page )
		{
			if($page['data']['active']) {
				$html .= '<strong>';
			}

			$html .= $page['data'];

			if($page['data']['active']) {
				$html .= '</strong>';
			}
		}

		$html .= $list['next']['data'];
		$html .= $list['end']['data'];
		$html .= ' »';
	}

	$html .= "</span>";
	return $html;
}

function pagination_item_active(&$item) {
	return "<a href=\"".$item->link."\" title=\"".$item->text."\">".$item->text."</a>";
}

function pagination_item_inactive(&$item) {
	return "<span>".$item->text."</span>";
}
?> 


Can someone help me with this problem?

Kind regards,
Flyboeing
GreyHead 28 Nov, 2011
Hi Flyboeing,

If I remember the fixes in the other thread they used JavaScript to change the pagination entries so that the filters were remembered correctly. You'll need a similar snippet for the pagination code in your template.

Bob
flyboeing 28 Nov, 2011
Hi Bob,

I changed my template to the JA_Purity and tried the JavaScript in this topic.

I can't get it to work😢 I read all the posts and made the changes to the code that worked for the others. Maybe it ain't working because I am using ChronoForms for my form and the actioncode of my form is the CC-form?
flyboeing 29 Nov, 2011
After searching this forum, I took a look in the "How to add a Search to a Connectivity form!" topic. On page 3 you find the post Vales where he had found the solution to the pagination problem.
Link to topic

With the code below the pagination is working, but I encountered an other problem by using this code.

<?php
$search_array = array('reg', 'aircraft', 'fotograaf', 'year', 'month', 'day', 'owner2', 'type', 'section');
$where = array();
foreach ( $search_array as $search ) {
  $value = JRequest::getVar($search, '' , 'post');
  if ( $value ) {
    $where[] = " $search LIKE '%$value%' ";
  }
}
$images = JRequest::getString('images_only', '', 'post');
if ( $images ) {
  $where[] = "`photo` != '' ";
}
$ac = JRequest::getString('ac_only', '', 'post');
if ( $ac ) {
  $where[] = "`ac` != '' ";
}
$remarks = JRequest::getString('remarks_only', '', 'post');
if ( $remarks ) {
  $where[] = "`remarks` != '' ";
}
$filter_catid =& JRequest::getInt('filter_catid', 0, 'post');
     if ( $filter_catid ) {
       echo " WHERE `id` LIKE '$filter_catid' ";
     }
if (empty($cerca) and (JRequest::getVar('submit','no','POST')=="Trova")) {
$session->set('where','0','zoeken');
JRequest::setVar('limitstart',0,'Get');
}
if ( !empty($where) ){
echo " WHERE ".implode(' AND ', $where);
$session->set('where',$where,'zoeken');          
}
elseif ((JRequest::getVar('submit','no','POST')<>"Trova") and  ($session->get('where',0,'zoeken')<>0)) {
$where=$session->get('where',0,'zoeken');
echo " WHERE ".implode(' AND ', $where);
}
else
{
echo "";
}
?>


I have a page where the entire database is shown (with pagination). When I search (for example I search for F50), I will get 3 pages of results. When I go back to my overview (the entire list of records) it remembers my search word, so only 3 pages are shown. Does someone has a solution for this?
GreyHead 29 Nov, 2011
Hi flyboeing,

I think that you need to detect when the form is supposed to show the full list - using something in the URL perhaps. If you check that then you can remove the filter word or skip that part of the WHERE code.

Bob
flyboeing 29 Nov, 2011
Thank you for pointing me in the right direction!🙂
I found an other solution that works very well for me. I copied the entire CC form and use one for the search results and one to show te entire database.
This topic is locked and no more replies can be posted.