Jump to content

Lister Selector


Robin S
 Share

Recommended Posts

Lister Selector

A Process module that uses Lister/ListerPro, but with a selector string input instead of the normal InputfieldSelector filters.

Features

  • For power users, typing a selector string is often faster and more intuitive than fiddling with InputfieldSelector. It also lets you copy/paste selector strings that you might be using somewhere else in your code.

  • Allows the Lister rows to be sorted by multiple fields (not possible in Lister/ListerPro)

  • Allows the use of OR-groups (not possible in Lister/ListerPro)

  • If ListerPro is installed you can run ListerPro actions on the listed pages - the available actions are defined in the module config.

  • Bookmarks can be configured in the module config and accessed via the flyout menu for the module page. For your convenience you can copy/paste a bookmark string from the note at the bottom of the Lister Selector results.

Usage

  • Type your selector string on the Selector tab. The selector is applied when the "Selector string" field is blurred, so hit Tab when you have finished typing your selector.

  • Unlike Lister/ListerPro, you can't sort results by clicking the column headings. Control the sort within the selector string instead.

  • Superusers can jump to the module config (e.g. to create a bookmark) by clicking the cog icon at the top right of the module interface.

  • The module is mostly intended for use by superusers, because in most cases site editors won't understand the ProcessWire selector string syntax. If you want another role to be able to access Lister Selector then give the role the "lister-selector" permission. Only superusers can define bookmarks because in ProcessWire module config screens are only accessible to superusers.

Screenshots

Process page

lister-selector

Module config (when ListerPro is installed)

lister-selector-config

Advanced

If for any reason you want to create dynamic bookmark links to Lister Selector for a given selector you can do that like this:

/** @var $pls ProcessListerSelector */
$pls = $modules->get('ProcessListerSelector');
// Define selector
$selector = "template=foo, title%=bar";
// Define columns (optional)
$columns = 'title,modified';
$pls_link = $pls->getProcessPage()->url . '?bm=' . $pls->urlSafeBase64Encode($selector . ':' . $columns);
echo "<a href='$pls_link'>My link</a>";

 

https://github.com/Toutouwai/ProcessListerSelector
https://modules.processwire.com/modules/process-lister-selector/

  • Like 12
  • Thanks 1
Link to comment
Share on other sites

@Robin S Excellent module! Thanks.

I have just tried it, and I noticed that the pagination doesn't work. It still works with all other Lister Pro instances. Is this intentional (same as with not being able to sort by clicking on table headings) ? Clicking on any of the pag. numbers actually loads the AJAX file, i.e. I see

XHR finished loading: POST "https://mysite.com/admin/setup/lister-selector/page2".

Google Chrome, Win 10, latest PW version, no JS/console errors.

  • Like 1
Link to comment
Share on other sites

4 hours ago, dragan said:

I have just tried it, and I noticed that the pagination doesn't work.

Thanks for alerting me to this. In v0.1.0, if you didn't supply a limit as part of the selector string then all the matching pages are listed, which strictly speaking is the correct result. But it seems that Lister doesn't expect this scenario and renders pagination numbers as if a limit of 25 was supplied. Clicking these numbers doesn't do anything though because actually all the pages are already listed.

But I think for most cases it's best to for Lister Selector to apply a default limit of 25 if none is supplied in the selector string - that way it's more in line with how Lister and Lister Pro behave. So I've changed to this in v0.1.1. And if you want a different limit you can supply it in the selector string (and you can use limit=0 if you want to see all results at once, but be aware that Lister will then render the incorrect pagination once again).

  • Like 2
Link to comment
Share on other sites

  • 8 months later...
11 hours ago, PWaddict said:

It seems that the columns are not saved with the bookmark. Are you planning to add that feature?

In v0.1.2 I've added support for columns to be saved in bookmarks. See the updated readme for details, and the screenshot for how you can easily copy/paste a bookmark string from the bottom of the Lister Selector results.

13 hours ago, PWaddict said:

Any idea how to get the values instead of the titles on a specific options field with a hook?

Are you able to do this in the core Lister or Lister Pro? This module uses Lister/ListerPro internally and doesn't do anything different with the results section. So maybe a question for the general forum or Lister Pro board rather than for this module thread.

  • Thanks 1
Link to comment
Share on other sites

It's buggy not only on page fields. Well, I go to the columns to set the fields and I'm getting the results instantly on lister. Then I save the bookmark. If I visit the bookmark, the last 2 columns fields (page fields) are not displayed in the lister. They're missing from columns too even though the bookmark string I saved on Bookmarks is correct.

I re-added those 2 page fields in columns but this time I changed their position and saved the bookmark. Now when I visit the bookmark, the 2 page fields are displayed on the lister but the last one field (options field) is missing.

Link to comment
Share on other sites

@PWaddict, when you change the bookmark in the module config, save, and then check the Lister results, are you doing this each time via the flyout menu?

2021-04-24_112405.png.d37cbd29234a223a75a1136641a027b3.png

In case it's not obvious, the settings for a bookmark are communicated to the Lister via the bookmark URL. The selector and columns are encoded into the "bm" parameter:

2021-04-24_112128.png.fcd0d0b133c24c7112c01891b689ffa4.png

When you change a bookmark and save the module config the link in the bookmarks flyout menu changes to use the updated "bm" parameter. This means that if you navigated to the module config from a previous bookmark you can't use the browser back button to see the updated bookmark results in the Lister because you'll be returning to the old URL. Likewise, you can't have the Lister open in one tab and change the bookmark settings in another tab and then just refresh the Lister tab.

If this doesn't solve your issue I'll need to get some steps to follow for a test case that will let me reproduce the issue.

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

×
×
  • Create New...