Jump to content
cjx2240

Pagination breaks with my unusual setup

Recommended Posts

Hello

Following a few guides on removing parent urls, and multilingual site setups, I have create multiple homepages for my website. For the parent language however, I've removed the parent name from the URL using the following in ready.php (mashed together from some other threads - on a side note please let me know if this is a terrible approach)

wire()->addHookBefore('Page::path', function($event) {
    $page = $event->object;
    if($page->rootParent(1057)) {
        $event->replace = true;
        $parents = "/";
        foreach($page->parents() as $parent) {
            if($parent->id != 1 && $parent->id != 1057) {
                $parents .= "$parent->name/";
            }
        }
        $event->return = $parents.$page->name."/";
    }
});

There's more to it than this, but I think this is the relevant part. And it's working great everywhere, except when it comes to rendering pagination [edit: within a repeater matrix, I should mention], for which my URLs are doubling up when they render, like so:

/parent/page/parent/page/page2

Any ideas how I can prevent this would be greatly appreciated.

Share this post


Link to post
Share on other sites

Do you use MarkupPagerNav module? 

If so, there is 'baseUrl' property where probably you should pass your modified page URL

  • Thanks 1

Share this post


Link to post
Share on other sites

Hey thanks for the idea, weirdly I set the baseUrl to a blank string, and that fixed it. I can't say I'm satisfied with understanding where things went wrong, but at least I can move forward for now!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...