How do you remove pagination from search results & use next/previous instead?

General questions relating to Joomla! 3.x. Please consider the availability of third-party templates and extensions when deciding which Joomla version to use.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Post Reply
lip420
Joomla! Explorer
Joomla! Explorer
Posts: 451
Joined: Thu Feb 17, 2011 6:13 am

How do you remove pagination from search results & use next/previous instead?

Post by lip420 » Fri Mar 02, 2018 7:13 am

I am not sure if this is possible but I am wondering if I can just use a previous/next button like on the articles pages for the search results pages?
Want a fast template? Get 100% on Pagespeed out of the box. Fast & minimalistic: http://www.inghh.com/jspeed/

itoctopus
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4027
Joined: Mon Nov 25, 2013 4:35 pm
Location: Montreal, Canada
Contact:

Re: How do you remove pagination from search results & use next/previous instead?

Post by itoctopus » Mon Mar 05, 2018 9:53 pm

It is possible - essentially you will need to override the pagination layout. Check out how it is overridden in the protostar template (under templates/protostart/html/pagination.php ).
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter

lip420
Joomla! Explorer
Joomla! Explorer
Posts: 451
Joined: Thu Feb 17, 2011 6:13 am

Re: How do you remove pagination from search results & use next/previous instead?

Post by lip420 » Tue Mar 06, 2018 10:29 pm

What lines do I remove to just keep the Prev and Next on the page for mobile and desktop?

Code: Select all

<?php
/**
 * @package     Joomla.Site
 * @subpackage  Templates.protostar
 *
 * @copyright   Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

/**
 * 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
 */

/**
 * Renders the pagination footer
 *
 * @param   array   $list  Array containing pagination footer
 *
 * @return  string         HTML markup for the full pagination footer
 *
 * @since   3.0
 */
function pagination_list_footer($list)
{
	$html = "<div class=\"pagination\">\n";
	$html .= $list['pageslinks'];
	$html .= "\n<input type=\"hidden\" name=\"" . $list['prefix'] . "limitstart\" value=\"" . $list['limitstart'] . "\" />";
	$html .= "\n</div>";

	return $html;
}

/**
 * Renders the pagination list
 *
 * @param   array   $list  Array containing pagination information
 *
 * @return  string         HTML markup for the full pagination object
 *
 * @since   3.0
 */
function pagination_list_render($list)
{
	// Calculate to display range of pages
	$currentPage = 1;
	$range = 1;
	$step = 5;
	foreach ($list['pages'] as $k => $page)
	{
		if (!$page['active'])
		{
			$currentPage = $k;
		}
	}
	if ($currentPage >= $step)
	{
		if ($currentPage % $step === 0)
		{
			$range = ceil($currentPage / $step) + 1;
		}
		else
		{
			$range = ceil($currentPage / $step);
		}
	}

	$html  = '<nav role="navigation" aria-label="' . JText::_('JLIB_HTML_PAGINATION') . '">';
	$html .= '<ul class="pagination-list">';
	$html .= $list['start']['data'];
	$html .= $list['previous']['data'];

	foreach ($list['pages'] as $k => $page)
	{
		if ($k !== $currentPage && $k !== $range * $step - $step
			&& ($k % $step === 0 || $k === $range * $step - ($step + 1))
			&& in_array($k, range($range * $step - ($step + 1), $range * $step)))
		{
			$page['data'] = preg_replace('#(<a.*?>).*?(</a>)#', '$1...$2', $page['data']);
		}

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

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

	$html .= '</ul>';
	$html .= '</nav>';
	return $html;
}

/**
 * Renders an active item in the pagination block
 *
 * @param   JPaginationObject  $item  The current pagination object
 *
 * @return  string                    HTML markup for active item
 *
 * @since   3.0
 */
function pagination_item_active(&$item)
{
	$class = '';

	// Check for "Start" item
	if ($item->text === JText::_('JLIB_HTML_START'))
	{
		$display = '<span class="icon-first" aria-hidden="true"></span>';
		$aria    = JText::sprintf('JLIB_HTML_GOTO_POSITION', strtolower($item->text));
	}

	// Check for "Prev" item
	if ($item->text === JText::_('JPREV'))
	{
		$display = '<span class="icon-previous" aria-hidden="true"></span>';
		$aria    = JText::sprintf('JLIB_HTML_GOTO_POSITION', strtolower($item->text));
	}

	// Check for "Next" item
	if ($item->text === JText::_('JNEXT'))
	{
		$display = '<span class="icon-next" aria-hidden="true"></span>';
		$aria    = JText::sprintf('JLIB_HTML_GOTO_POSITION', strtolower($item->text));
	}

	// Check for "End" item
	if ($item->text === JText::_('JLIB_HTML_END'))
	{
		$display = '<span class="icon-last" aria-hidden="true"></span>';
		$aria    = JText::sprintf('JLIB_HTML_GOTO_POSITION', strtolower($item->text));
	}

	// If the display object isn't set already, just render the item with its text
	if (!isset($display))
	{
		$display = $item->text;
		$aria    = JText::sprintf('JLIB_HTML_GOTO_PAGE', $item->text);
		$class   = ' class="hidden-phone"';
	}

	return '<li' . $class . '><a title="' . $item->text . '" href="' . $item->link . '" class="pagenav" aria-label="' . $aria . '">' . $display . '</a></li>';

}

/**
 * Renders an inactive item in the pagination block
 *
 * @param   JPaginationObject  $item  The current pagination object
 *
 * @return  string  HTML markup for inactive item
 *
 * @since   3.0
 */
function pagination_item_inactive(&$item)
{
	// Check for "Start" item
	if ($item->text === JText::_('JLIB_HTML_START'))
	{
		return '<li class="disabled"><a><span class="icon-first" aria-hidden="true"></span></a></li>';
	}

	// Check for "Prev" item
	if ($item->text === JText::_('JPREV'))
	{
		return '<li class="disabled"><a><span class="icon-previous" aria-hidden="true"></span></a></li>';
	}

	// Check for "Next" item
	if ($item->text === JText::_('JNEXT'))
	{
		return '<li class="disabled"><a><span class="icon-next" aria-hidden="true"></span></a></li>';
	}

	// Check for "End" item
	if ($item->text === JText::_('JLIB_HTML_END'))
	{
		return '<li class="disabled"><a><span class="icon-last" aria-hidden="true"></span></a></li>';
	}

	// Check if the item is the active page
	if (isset($item->active) && $item->active)
	{
		$aria = JText::sprintf('JLIB_HTML_PAGE_CURRENT', $item->text);

		return '<li class="active hidden-phone"><a aria-current="true" aria-label="' . $aria . '">' . $item->text . '</a></li>';
	}

	// Doesn't match any other condition, render a normal item
	return '<li class="disabled hidden-phone"><a>' . $item->text . '</a></li>';
}
Want a fast template? Get 100% on Pagespeed out of the box. Fast & minimalistic: http://www.inghh.com/jspeed/

mabdelaziz
Joomla! Intern
Joomla! Intern
Posts: 87
Joined: Mon Aug 21, 2006 10:56 am
Location: Alexandria, Egypt
Contact:

Re: How do you remove pagination from search results & use next/previous instead?

Post by mabdelaziz » Wed Mar 07, 2018 10:03 am

Try to remove these lines:

Code: Select all

foreach ($list['pages'] as $k => $page)
   {
      if ($k !== $currentPage && $k !== $range * $step - $step
         && ($k % $step === 0 || $k === $range * $step - ($step + 1))
         && in_array($k, range($range * $step - ($step + 1), $range * $step)))
      {
         $page['data'] = preg_replace('#(<a.*?>).*?(</a>)#', '$1...$2', $page['data']);
      }

      $html .= $page['data'];
   }
This will remove the page links, while start, previous, next and end will stay there.
Joomla extensions, tutorials and blogs
https://www.joomreem.com

Custom development is available.
Mohamed Abdelaziz

lip420
Joomla! Explorer
Joomla! Explorer
Posts: 451
Joined: Thu Feb 17, 2011 6:13 am

Re: How do you remove pagination from search results & use next/previous instead?

Post by lip420 » Wed Mar 07, 2018 11:13 am

Thanks. I'll try. Know how to remove the start and end?
Want a fast template? Get 100% on Pagespeed out of the box. Fast & minimalistic: http://www.inghh.com/jspeed/

mabdelaziz
Joomla! Intern
Joomla! Intern
Posts: 87
Joined: Mon Aug 21, 2006 10:56 am
Location: Alexandria, Egypt
Contact:

Re: How do you remove pagination from search results & use next/previous instead?

Post by mabdelaziz » Wed Mar 07, 2018 11:21 am

lip420 wrote:Thanks. I'll try. Know how to remove the start and end?
Yes, remove these 2 lines:

Code: Select all

$html .= $list['start']['data'];

Code: Select all

$html .= $list['end']['data'];
Joomla extensions, tutorials and blogs
https://www.joomreem.com

Custom development is available.
Mohamed Abdelaziz

lip420
Joomla! Explorer
Joomla! Explorer
Posts: 451
Joined: Thu Feb 17, 2011 6:13 am

Re: How do you remove pagination from search results & use next/previous instead?

Post by lip420 » Wed Mar 07, 2018 5:00 pm

Thanks, there are 2 bullet lists there now but the words/links "Prev" and Next" aren't on the page?
Want a fast template? Get 100% on Pagespeed out of the box. Fast & minimalistic: http://www.inghh.com/jspeed/

mabdelaziz
Joomla! Intern
Joomla! Intern
Posts: 87
Joined: Mon Aug 21, 2006 10:56 am
Location: Alexandria, Egypt
Contact:

Re: How do you remove pagination from search results & use next/previous instead?

Post by mabdelaziz » Wed Mar 07, 2018 5:06 pm

I think it maybe a css issue, can you see the words in the html source?
Joomla extensions, tutorials and blogs
https://www.joomreem.com

Custom development is available.
Mohamed Abdelaziz

lip420
Joomla! Explorer
Joomla! Explorer
Posts: 451
Joined: Thu Feb 17, 2011 6:13 am

Re: How do you remove pagination from search results & use next/previous instead?

Post by lip420 » Wed Mar 07, 2018 5:11 pm

Yes, I think so...

It says this:

<div class="search-pagination">
<div class="pagination">
<nav role="navigation" aria-label="Pagination"><ul class="pagination-list"><li><a title="Prev" href="/search-results?q=japan&limitstart=0" class="pagenav" aria-label="Go to prev page"><span class="icon-previous" aria-hidden="true"></span></a></li><li class="disabled"><a><span class="icon-next" aria-hidden="true"></span></a></li></ul></nav> </div>
<div class="search-pages-counter">
Results <strong>101</strong> - <strong>131</strong> of <strong>131</strong> </div>
</div>
Want a fast template? Get 100% on Pagespeed out of the box. Fast & minimalistic: http://www.inghh.com/jspeed/

lip420
Joomla! Explorer
Joomla! Explorer
Posts: 451
Joined: Thu Feb 17, 2011 6:13 am

Re: How do you remove pagination from search results & use next/previous instead?

Post by lip420 » Wed Mar 07, 2018 6:12 pm

I tried switching the template so it doesn't seem to be a css issue. Not sure the suggest edits are correct.

I tried deleting all of the:

Code: Select all

// Check for "Prev" item
and

Code: Select all

// Check for "Next" item
And the text would show but not in mobile or smaller screens.
Want a fast template? Get 100% on Pagespeed out of the box. Fast & minimalistic: http://www.inghh.com/jspeed/

lip420
Joomla! Explorer
Joomla! Explorer
Posts: 451
Joined: Thu Feb 17, 2011 6:13 am

Re: How do you remove pagination from search results & use next/previous instead?

Post by lip420 » Wed Mar 07, 2018 6:25 pm

Ok. I think I got it...

I deleted the "hidden-phone" here:

Code: Select all

$class   = ' class="hidden-phone"';
Want a fast template? Get 100% on Pagespeed out of the box. Fast & minimalistic: http://www.inghh.com/jspeed/

mabdelaziz
Joomla! Intern
Joomla! Intern
Posts: 87
Joined: Mon Aug 21, 2006 10:56 am
Location: Alexandria, Egypt
Contact:

Re: How do you remove pagination from search results & use next/previous instead?

Post by mabdelaziz » Wed Mar 07, 2018 6:30 pm

Well, as long as you want it to show in small screens and mobiles, this is ok.
Joomla extensions, tutorials and blogs
https://www.joomreem.com

Custom development is available.
Mohamed Abdelaziz

lip420
Joomla! Explorer
Joomla! Explorer
Posts: 451
Joined: Thu Feb 17, 2011 6:13 am

Re: How do you remove pagination from search results & use next/previous instead?

Post by lip420 » Thu Mar 08, 2018 12:38 am

Yes, and I changed the css in "pagination-list" to "pager pagenav" which is like the article prev next button in protostar.
Want a fast template? Get 100% on Pagespeed out of the box. Fast & minimalistic: http://www.inghh.com/jspeed/


Post Reply

Return to “General Questions/New to Joomla! 3.x”