Fixed <xf:pagenav> using incorrect router

AddonFlare

Well-known member
Affected version
2.0.10
<xf:pagenav> builds the "previous" and "next" links using the incorrect router if a macro from a different template type is called right before it

Example:
Admin template with the following code:
HTML:
<xf:title>{$pageTitle}</xf:title>

<xf:if is="$data is not empty">
    <div class="block-container">
        <div class="block-body">
            <xf:datalist data-xf-init="responsive-data-list">
                <thead>
                    <xf:datarow rowtype="header">
                        <xf:cell>User</xf:cell>
                        <xf:cell>Date</xf:cell>
                    </xf:datarow>
                </thead>
                <xf:macro template="public:my_public_macros_template"
                          name="macro_1" />
            </xf:datalist>
        </div>
    </div>
    <xf:pagenav page="{$page}" perpage="{$perPage}" total="{$total}"
                link="my/route"
                wrapperclass="js-filterHide block-outer block-outer--after" />
<xf:else />
    <div class="blockMessage">{{ phrase('no_items_to_display') }}</div>
</xf:if>

The URLs for the "previous" and "next" buttons use the public router (incorrect):
http://my-forum.com/index.php?my/route/&page=1, http://my-forum.com/index.php?my/route/&page=3, etc

The URLs for the page number (1,2,3,4,5) buttons use the admin router (correct):
http://my-forum.com/admin.php?my/route/&page=1, http://my-forum.com/admin.php?my/route/&page=2, etc

Possible solution that seems to solve this issue:

In file: /src/XF/Template/Templater.php
Change Line 2635

From: $router = $this->router;

To: $router = $this->getRouter();
 
Thank you for reporting this issue. The issue is now resolved and we are aiming to include that in the next XF release (2.0.11).

Change log:
Ensure xf:pagenav tags use correct router.
 
Top Bottom