XF 1.5 Easy way to get next page link in ViewPublic

grisha2217

Active member
Hi all. I want to get next page link like <link rel="next" href="threads/334644/page-2"> in json response
I know how to render page_nav template:
PHP:
$output['pageNav'] = $this->createTemplateObject(
            'market_index_page_nav',
            $this->_params
        );

But i want to get next page link
HTML:
<link rel="next" href="{xen:link $linkType, $linkData, '_params={$linkParams}', 'page={$nextPage}'}" />

I know how to render page nav:
PHP:
$pageNav = XenForo_Template_Helper_Core::helperPageNavHtml('public', $this->_params['itemsPerPage'], $this->_params['totalItems'], $this->_params['page'], 'market');

Next i created page_nav_next_page template:
HTML:
<xen:if is="{$nextPage}">
    <link rel="next" href="{xen:link $linkType, $linkData, '_params={$linkParams}', 'page={$nextPage}'}" />
</xen:if>

How i can render page_nav_next_page template with page nav params?
Thanks.
 
Solution

PHP:
$pageTotal = ceil($this->_params['totalItems'] / $this->_params['perPage']);
            if ($pageTotal > $this->_params['page'])
            {
                $output['nextPage'] = XenForo_Link::buildPublicLink('market', null, ['page' => $this->_params['page'] + 1] + $this->_params['pageNavParams']);
            }
 
Last edited:
Back
Top Bottom