Jump to content

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 11
  • Thanks 1

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Hi @Robin S That's a very useful module. Thank you.

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

  • Like 1

Share this post


Link to post
Share on other sites

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

  • Like 1

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Page reference fields on columns not getting saved with bookmarks.

Share this post


Link to post
Share on other sites
1 hour ago, PWaddict said:

Page reference fields on columns not getting saved with bookmarks.

I can't reproduce that.

2021-04-24_100510.png.2792360bddac090815f4f8da90381ce4.png

2021-04-24_100423.png.7776ac7e1e2261235ec4a4ee04347da7.png

 

Please explain in more detail.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
20 minutes ago, Robin S said:

@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?

Yes

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.

  • Similar Content

    • By michelangelo
      Hello guys,
      I have an issue that might be solved with the Lister module or ListerPro. I don't want to order the paid module if it's not necessary. That's why I wanted to ask first.
      I have multiple images that my client wants to be able to go through and categorise them. The structure in a lister looks like this:

      The "Category Reference" is related to a few categories that are in multiple groups:

      I would like to have those options show up in the Lister and be able to quickly select them.
      This is how the categories look like in the Image page itself:

      Is there a way to do it with the built in PW modules? I just want to have the table-like view in the lister and in the "Category references" to have my three options "Cloth, China, Surgical".

      Thanks!
    • By Peter Knight
      Hey I'm building my first new site in well over a year and am a little rusty on selectors but particularly retrieving sub-fields of selected pages.
      I am trying to output the meta data of a blog post as follows.
      [Person Name] is just a field with a Page Reference and simple enough.
      [Job Title] is the sub-field within the page that was referenced above.
      I actually have it working with the following:
      Posted by: <?php if($page->insight_author) { echo $page->insight_author("<a href='{url}'>{title}</a>");} ?> , <?php $roles = $page->insight_author; foreach ($roles as $role) { echo "{$role->staff_role}";} ?> but was wondering how to do this with selector sub-selectors instead. My current code is probably quite 'old school'?
      Thanks
       
    • By theoretic
      Hi there! And thanks for Processwire!
      I have an interesting task which i cannot fulfill as i want. Maybe someone could help me please?
      Let's imagine a simple page structure of this kind:
      Category 1
      + Item 1.1
      + Item 1.2
      Category 2
      + Item 2.1
      + Item 2.2
      My task is to attach some items to more than one category, at least to show some items on different frontend category pages. With PW, it's a piece of cake. I've just created a field called Items (of type Page Reference) and attrached it to Category template. Since i have lots of items inside each category i preferred to use Page Autocomplete input for my Items field. The pages available for autocomplete are restricted by a very simple selector:
      template=item
      It works like a charm. But later i decided to make this autocomplete even smarter and to exclude current category children items from it. I tried to update my selector this way...
      template=item,parent!=(page)
      ...and oops, this broke my selector. My autocomplete founds nothing. Sorry, i had to replace the square braces by () because of this forum limitations, i swear i'm using square brackets in real-life selector!
      What am i doing wrong? And is there any way to include current page info in autocomplete-related selectors? Thanks in advance!
       
    • By ottogal
      Hello all,
      using PW 3.0.148 with the regular site profile for a blog, I got an an empty pagination output when I had a Toggle field in the selector.
      The Toggle Fieldtype was introduced with https://processwire.com/blog/posts/pw-3.0.139/ .
      The selector resulting in empty pagination:
      $posts = $pages->find("parent=blog, sort=-date, limit=10, toggle_field=0"); It worked well, when I replaced the Toggle field with a Checkbox field:
      $posts = $pages->find("parent=blog, sort=-date, limit=10, checkbox_field=0"); So the prerequisites for the pagination to work are given.
      The settings for the Toggle field were:
      Formatted value: Integer Label Type: Yes/No Input Type: Toggle buttons Default selected option: No Thanks for any hints!
    • By snck
      Hi there,
      I have a problem constructing a selector that finds all pages that refer to pages with a specific template.
      I have pages using an event template and I want to show events based on a specific context. In this example I want to filter the results and only show event pages that relate to a specific template (exhibitions) in their page field related_pages.
      What I tried:
      $events = $pages->find("template=event, related_pages.template.name=exhibition"); Unfortunately it does not work (0 results).
      Same with this:
      $events = $pages->find("template=event, related_pages=[template.name=exhibition]"); At the moment I am helping myself with the following lines, but I have a strong feeling that there is a more efficient solution:
      $events = $pages->find("template=event"); foreach($events as $event){ if(!count($event->related_pages->find("template=exhibition"))){ $events->remove($event); } }  
      I really hope that one of you can help me out.
      Thanks in advance!
      Flo
×
×
  • Create New...