Jump to content

Pagination breaks with my unusual setup


cjx2240
 Share

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...