Jump to content

ProcessPageLister and pagination in a module


MSP01
 Share

Recommended Posts

I'm trying to make a simple module to help handling some specific pages. There's a simple dashboard and under that a page with ProcessPageLister, like the simplified example below. 

public function ___execute() {
    // Dashboard
}

public function ___executeBrowser() {
	// Browser
    $browser = $this->modules->get('ProcessPageLister');
    return $browser->execute();
}

Problem is when you use the pagination ProcessPageLister creates, you end up in Dashboard instead of staying inside the "Browser". 

What should I do to make this work correctly?

Link to comment
Share on other sites

16 hours ago, MSP01 said:

What should I do to make this work correctly?

You can set the base URL for MarkupPagerNav that is used for the Lister pagination.

public function ___executeBrowser() {
	// Before MarkupPagerNav is rendered
	$this->addHookBefore('MarkupPagerNav::render', function(HookEvent $event) {
		$pager = $event->object;
		// Set base URL to the current page + URL segment
		$pager->setBaseUrl($this->wire()->page->url . 'browser/');
	});

	$browser = $this->modules->get('ProcessPageLister');
	return $browser->execute();
}

 

  • Like 1
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...