/**
* Helper to get page navigation (all pages, for scrolling pagenav version).
*
* @param string $templateClass Name of the template class to instantiate
* @param string $linkFunction Name of the linking function to call (in this class)
* @param integer $perPage Items to display per page
* @param integer $totalItems Total number of items
* @param integer $currentPage Current page number
* @param string $linkType Type of link to create
* @param mixed $linkData Data for the link
* @param array $linkParams List of key value params for the link; page will be set as needed
* @param array $options Options to control the building
*
* @return string|XenForo_Template_Abstract
*/
protected static function _getPageNav($templateClass, $linkFunction, $perPage, $totalItems, $currentPage,
$linkType, $linkData = null, array $linkParams = array(), array $options = array()
)
{
// abort if there are insufficient items to make multiple pages
if ($totalItems < 1 || $perPage < 1)
{
return '';
}
$options = array_merge(
array(
'unreadLink' => '',
'template' => 'page_nav',
'displayRange' => 2 //TODO: make this come from an option?
),
$options
);
$unreadLinkHtml = htmlspecialchars($options['unreadLink'], ENT_COMPAT, 'iso-8859-1', false);
$pageTotal = ceil($totalItems / $perPage);
// abort if there is only one page
if ($pageTotal <= 1)
{
if (!empty($options['unreadLink']))
{
return new $templateClass($options['template'], array(
'unreadLinkHtml' => $unreadLinkHtml,
'pageTotal' => $pageTotal
));
}
return '';
}
$currentPage = min(max($currentPage, 1), $pageTotal);
// number of pages either side of the current page
$range = $options['displayRange'];
$scrollSize = 1 + 2 * $range;
$scrollThreshold = $scrollSize + 2;
if ($pageTotal >$scrollThreshold)
{
$startPage = max(2, $currentPage - $range);
$endPage = min($pageTotal, $startPage + $scrollSize);
$extraPages = $scrollSize - ($endPage - $startPage);
if ($extraPages > 0)
{
$startPage -= $extraPages;
}
}
else
{
$startPage = 2;
$endPage = $pageTotal;
}
if ($endPage > $startPage)
{
$endPage--;
$pages = range($startPage, $endPage);
}
else
{
$pages = array();
}
if (isset($linkParams['_params']) && is_array($linkParams['_params']))
{
$tempParams = $linkParams['_params'];
unset($linkParams['_params']);
$linkParams = array_merge($tempParams, $linkParams);
}
$templateVariables = array(
'pageTotal' => intval($pageTotal),
'currentPage' => $currentPage,
'pages' => $pages,
'range' => $range,
'scrollThreshold' => $scrollThreshold,
'startPage' => $startPage,
'endPage' => $endPage,
'prevPage' => ($currentPage > 1 ? ($currentPage - 1) : false),
'nextPage' => ($currentPage < $pageTotal ? ($currentPage + 1) : false),
'pageNumberSentinel' => XenForo_Application::$integerSentinel,
'linkType' => $linkType,
'linkData' => $linkData,
'linkParams' => $linkParams,
'maxDigits' => strlen($pageTotal),
'unreadLinkHtml' => $unreadLinkHtml
);
$template = new $templateClass($options['template'], $templateVariables);
return $template;
}
It might be a template edit. I will look later.
... I have to ask, though, why?
I'm not sure that was the reason at the time. A year ago XenForo didn't have responsive design so it would have looked no better or worse on mobile.
$range = $options['displayRange'];
$range = 1;
.PageNav .scrollable
{
width: 70px;
}
$currentPage = min(max($currentPage, 1), $pageTotal);
// number of pages either side of the current page
//$range = $options['displayRange']; // old setting
$range = 0; // new setting
//$scrollSize = 1 + 2 * $range; //old setting
$scrollSize = 2; // new setting
$scrollThreshold = $scrollSize + 2;
if ($pageTotal > $scrollThreshold)
{
$startPage = max(2, $currentPage - $range);
$endPage = min($pageTotal, $startPage + $scrollSize);
$extraPages = $scrollSize - ($endPage - $startPage);
if ($extraPages > 0)
{
$startPage -= $extraPages;
}
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.