1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

xen:pagenav Question

Discussion in 'XenForo Development Discussions' started by attemis, Oct 26, 2014.

  1. attemis

    attemis Member

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

    This is my pagenav 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?
    Last edited: Oct 26, 2014
  2. Chris D

    Chris D XenForo Developer Staff Member

    This is handled in the route controller.

    Look at: XenForo/Route/Prefix/Threads.php for an example.
    attemis likes this.
  3. attemis

    attemis Member

    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?
    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');
  4. Chris D

    Chris D XenForo Developer Staff Member

    I have just spotted a mistake in your pagenav code.

    The link should not use {xen:link}.

    e.g. for threads it is:
    <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.
    attemis likes this.
  5. attemis

    attemis Member

    Okay thank you! I'll try that :)
  6. attemis

    attemis Member

Share This Page