xen:pagenav Question

attemis

Member
Hey,
today i am going to make the pagenav links of my addon more beautiful.
Xenforo threads get the page integer this way:
https://domain.tld/threads/example.1/page-2
On my addon (and also on xenforo's memberlist) the page number is get this way:
https://domain.tld/route/example?page=3
When i change the url of my addon manually, i can use
https://domain.tld/route/example/page-3
But my xen: pagenav displays only https://domain.tld/route/example?page=3 links :(

This is my pagenav code:
Code:
<xen:pagenav link="{xen:link 'route/example'}" page="{$page}" perpage="{$perPage}" total="{$totalPlayers}" />

Is it possible to get the page number "fancy" like the xenforo threads do?
attemis
 
Last edited:
This is handled in the route controller.

Look at: XenForo/Route/Prefix/Threads.php for an example.
 
Thank you for your fast answer, but my code is based on XenForo/Route/Prefix/Threads.php
The requests to https://domain.tld/route/example/page-2 are already working fine.
Only the pagenav doesn't link to the "fancy" page parameters.
Here is my route class, can you see a mistake/error?
Code:
class Addon_Route_Test implements XenForo_Route_Interface
{
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        $action = $router->resolveActionWithStringParam($routePath, $request, 'request');
        $action = $router->resolveActionAsPageNumber($action, $request);
        return $router->getRouteMatch('Addon_ControllerPublic_Test', $action, 'test');
    }

    public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
    {
        $action = XenForo_Link::getPageNumberAsAction($action, $extraParams);
        return XenForo_Link::buildBasicLinkWithStringParam($outputPrefix, $action, $extension, $data, 'request');
    }
}
 
I have just spotted a mistake in your pagenav code.

The link should not use {xen:link}.

e.g. for threads it is:
Code:
<xen:pagenav link="threads" linkdata="{$thread}"
    page="{$page}" perpage="{$postsPerPage}" total="{$totalPosts}"
    unreadlink="{$unreadLink}" />

Note, the link param only contains the route prefix, the actual data for the link is passed via the linkdata attribute.
 
Top Bottom