Jump to content

Supplying a variable to a lister filter


MarkE
 Share

Recommended Posts

Is it possible (in a custom module) to supply a variable to a lister page? My custom module ("ProcessReports") simply lists a number of reports (mostly lister bookmarks). Some of these bookmarks have a filter using a date comparison and I want the module to supply a date (based on the current date) before displaying the lister, rather than the user having to change it each time.

Link to comment
Share on other sites

Check out the PLUs (Page Lister URLs) module.

Or if you want to go the hook route try manipulating the defaultSelector property of the Lister:

$wire->addHookBefore('ProcessPageLister::execute', function(HookEvent $event) {
	// Only for the initial load, not for subsequent user changes
	if($event->config->ajax) return;
	$lister = $event->object;

	// Do something here to identify if this is the lister you want to modify and return early if not

	// Then manipulate the defaultSelector property...
	// E.g. append to the existing defaultSelector
	$lister->defaultSelector .= ', your_field=your_value';
});

 

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