Jump to content
a-ok

PageField – limit number of choices

Recommended Posts

11 hours ago, tpr said:

I reckon the same question is about to emerge for the rest of the PageField types, isn't it

Yeah, limiting users is fun! :P 

Share this post


Link to post
Share on other sites
16 hours ago, tpr said:

I reckon the same question is about to emerge for the rest of the PageField types, isn't it? 😀

Would be cool to add support where possible. :)

Not sure how you've handled the AsmSelect limit in the as-yet-unreleased AOS update, but maybe part of the JS could be broken off into a piece that is generic to all Page Reference inputfields. It would identify the underlying form element that contains the actual field value, and on change it would check if the limit is reached. If so it would add a class to inputfield container, and trigger some event for the container, e.g. 'limitReached'.

If you go that way others can contribute pull requests for the remaining Page Reference inputfield types without reinventing the wheel for the limit check. I'd be happy to contribute here.

  • Like 3

Share this post


Link to post
Share on other sites
On 2/22/2018 at 10:31 PM, tpr said:

It's done, will be added to the next aos update.

Hi @tpr,

Wonderful, elegant solution. I need this for my current project but I don't understand how I can get it. Have you made a module? Is it available?

Thanks!

Share this post


Link to post
Share on other sites

It works with asmSelect type only (atm). 

Install AdminOnSteroids module, enable AsmTweaks at the top, then scroll down to its config section (or click the "cog" icon in the AsmTweaks block's bottom-right corner to jump there). Here check "Add limit to AsmSelect" and save AOS. Finally, in your field's Input tab set the max number in the "Max limit of items" input field .

https://github.com/rolandtoth/AdminOnSteroids/wiki/AsmTweaks

  • Like 2

Share this post


Link to post
Share on other sites
On 2/23/2018 at 6:26 AM, tpr said:

I saw this follow-up question coming, 😀 I think that's also doable, will check that later. I reckon the same question is about to emerge for the rest of the PageField types, isn't it? 😀

Regarding Page Auto Complete fields I have the impression there already is a limit. In several templates I have a page field referring to a list of over 4000 places. When I want to add 'Paris, Île-de-France, France' from the list, that doesn't show up because the page are sorted alphabetically and the Page Auto Complete list starts with 'Paris Ier, Île-de-France, France || address 1', then 'Paris Ier, Île-de-France, France || address 2' and so on, then 'Paris IIe, Île-de-France, France || address 1' and so on. The list stops before just 'Paris, Île-de-France, France' shows up alphabetically.

It's ok to find other places in Paris because part of the street name will do in the Page Auto Complete field, but it's just not possible anymore to add 'Paris, Île-de-France, France'. Changing the Autocomplete search operator doesn't work for what I want either (still searching by other parts of the address).

This all happens in the admin pages, no front editing.

Share this post


Link to post
Share on other sites
On 7/2/2018 at 11:26 PM, BFD Calendar said:

It's ok to find other places in Paris because part of the street name will do in the Page Auto Complete field, but it's just not possible anymore to add 'Paris, Île-de-France, France'.

If I'n not wrong, @kongondo's VisualPageSelector module (commercial) should solve such an issue as it uses lister and its filters to select the related page:

quote: "electable pages as per page field settings + Lister filters"

see more: 

Or you might want to implement your own InputField which also uses ProcessWire's Lister and its user customizable page filter to select the page.

 

  • Like 1

Share this post


Link to post
Share on other sites

@BFD Calendar you can also use RockGrid to select Pages. It should be able to handle 100k pages and you could even add images just like in the screenshot of kongondo's module above

Share this post


Link to post
Share on other sites
3 minutes ago, bernhard said:

@BFD Calendar you can also use RockGrid to select Pages. It should be able to handle 100k pages and you could even add images just like in the screenshot of kongondo's module above

Thanks for the tip, actually I tried RockGrid on another site earlier today but it was far above my capabilities to do anything with it. (I was looking for something to generate detailed reports from Padloper sales)

Share this post


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

Or you might want to implement your own InputField which also uses ProcessWire's Lister and its user customizable page filter to select the page.

 

I've used Lister before but didn't know it could also be used to make a custom InputField....

Share this post


Link to post
Share on other sites
33 minutes ago, BFD Calendar said:

Thanks for the tip, actually I tried RockGrid on another site earlier today but it was far above my capabilities to do anything with it. (I was looking for something to generate detailed reports from Padloper sales)

Sorry to hear that. It's all about using the right RockFinder and sometimes it's easier/necessary to populate hidden fields with hooks to efficiently query the data. Did you try RockFinder Tester? Once you have the right RockFinder you can do everything that aggrid can do.

Using it as a page selector needs some additional (but not complicated) javascript, though.

  • Like 1

Share this post


Link to post
Share on other sites

I tried RockFinder Tester as well, but didn't find my way as I want either. I'm just an amateur programmer but nevertheless happy with ProcessWire capabilities for my needs as far as it gets. My main job is managing an Academic Design Workshop for 1500 students. The website (www.mekano.info) is just a side project next to operating lasercutters, CNC routers, a wide range of hand tools, and painting the studio floor during school holidays.

  • Like 1

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 louisstephens
      So I ran into a very strange issue today. I have a template with a pagetable and I went to add an item to it, when I went to select an image (for an image field) the page instantly threw up an error
      "ProcessPageSearchLive: No search specified"
      The page's content also switched to the image attached. This all worked perfectly last week (local mamp box). Has anyone experienced this before, and how did you solve it?
       

    • By Pip
      Hi everyone, 
      Is there a way for us to replicate the "http://mydomain.com/processwire/page/edit/?id=xxx" and change the template to match my site template? 
      I'm terribly happy with the admin / backend page edit. It covers literaly everything I want to empower my non super admin user in updating pages such as validation, repeater management, file upload. 
      I wish not to allow the users to see the backend for both security and aesthetic reasons. 
      Thanks and hope to hear from you soon. 
       
    • 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
    • By EyeDentify
      Hello dear PW gurus.

      I have stumbled over a strange error that i all of sudden got when trying to upload an image to a images field on a page.
      There where images allready stored in the field that i wanted to keep, but during the upload the error apear and after that all images are gone from the field and i can´t upload any, i just get the error every time.
      I am running ProcessWire 3.0.153 dev.
      Update:
      After looking in the assets folder i find the folder for the page and the image files seems to be there including the ones i tried to upload when the error occured.
      But they don´t show up in the images field in the page editor.
       
      The error reported:
       
      SQLSTATE[01000]: Warning: 1265 Data truncated for column 'ratio' at row 1 And here is a screenshot of the event:

      The TracyDebugger Error reporting:

      I hope you fine folks could point me in a direction.
      But it seems our old pal set_time_limit() is back.

      Regards, EyeDentify
    • By Spyros
      Hello
      I'm having a strange issue with the $page->find(), for some reason I'm missing some of the pages from the results. I found then that I was missing all the pages with the same "PAGE NAME". Is it a bug or am I missing something?
      PS 
      If I change the "PAGE NAME" of one of the missing ones then I'm retrieving the page without any problem.
      Thank you
×
×
  • Create New...