LostKobrakai

InputfieldChosenSelect

Recommended Posts

Just thinking out loud if you are looking for something to do :)

As if I didn't talk about other modules on the todo list in another thread. But actually it's not an inputfield which is bound to be used with FieldtypePage, as this states in the module declaration.

... extends InputfieldSelectMultiple implements InputfieldHasArrayValue

The module does add itself automatically to be usable with pages in the settings of FieldtypePage, so maybe it's only missing it's entry in FieldtypeOptions' settings. I'll test this tomorrow and if it's that way, I'll add the addition/removal to install() and uninstall().

  • Like 2

Share this post


Link to post
Share on other sites

I've just checked, the module does work out of the box with FieldtypeOptions, so nothing to do for me :)

Edit: At least for the "Interface".

Seems like Ryan did not include an option for adding new options from the inputfield by now, like it's for FieldtypePage. The thing I don't like about including it myself is, that I can't really guess a value for the field, while this would give the ability to change the wording afterwards, even if it's only a typo. Maybe we should first ask Ryan if he could implement a standartised way for auto values, then it would be easy to include a "add option" field like for pages. I'll open a feature request over on github.

  • Like 3

Share this post


Link to post
Share on other sites

Just a quick note - there seems to be a bit of an issue on touch screens. Not sure if it is something related to your module, or the chosen library itself, but the first time I tap on the field, it automatically selects and adds the first page to the list of selected items. After that I can tap again and no selections are made. 

This happened to me on Chrome on iOS, but I haven't tested other browsers/devices.

Share this post


Link to post
Share on other sites

Chosen is disabled on iPhone, iPod Touch, and Android mobile devices (more information).

That the statement on the projects page. I've just tested it on safari and it's not loading, so maybe chrome in iOS  isn't properly detected as mobile browser.

Share this post


Link to post
Share on other sites

Interesting - chosen actually works on tablet sized devices, but is disabled on phone sized ones. The issue I mentioned above doesn't seem to be an issue on Safari on tablets.

Having this not work on phone sized devices though is quite a problem - the selection of existing pages works well enough, but not being able to add new ones is a deal breaker for me. 

I haven't tried it yet, but there is this fork of chosen that claims to work with mobile devices:

https://github.com/rafalenden/chosen

Maybe your module could fallback to ASM select with a textarea (for creating new pages) if on phone sized? Or maybe some other option - there has to be a cleaner way :)

Not sure the best option yet - will think about it more later.

Share this post


Link to post
Share on other sites

If chosen is not working is should report this back, so I should be able to just unhide the textarea to allow adding of pages.

Edit: Just pushed a commit to add this. Now you can at least add pages. Will take a look at the fork later.

  • Like 1

Share this post


Link to post
Share on other sites

I've just added a new version of the module on the dev branch. A request for a single select inputfield powered by the chosen library came up on github. So I implemented it, which does mean the current inputfield is renamed to …SelectMultiple. I still want to add some more fitting styles, but it would also be nice to have some feedback if everything is still working for you guys, before I merge it to master.

  • Like 2

Share this post


Link to post
Share on other sites

I love this field type. A user of mine needs to select several pages from 100s and the tree traversal wasn't quick enough to be practical. One thing we do miss iS the ability to reorder chosen pages like the regular page select.

Is that on the horizon?

Share this post


Link to post
Share on other sites

If you mean drag and drop, that's already implemented.

Oh cool. I hadn't realised. Rushes off to check it....

Share this post


Link to post
Share on other sites

The drag and drop reordering works lovely. Thanks for letting me know.

Can I just chip in some thoughts? 

  • This is just a personal preference but I wonder if the selected items should matched the display of the normal Page Select results.
    IE stacked vertically with 100% width, trash icon and colored background. Then again, your way fits more selections into a smaller space.|
     
  • I wonder if the drag and drop could be refined a little. When I drag a selected page left or right, I see a dotted line which I don't think is necessary. It's also only 70% height of the field too which makes it look like a mistake. It's probably a part of the original jQuery setup?
     
  • Chrome has an annoying habit of trying to auto-fill the results and bringing up a selection of 'helpful' results.

But really, thanks for taking time to make this. It's a really cool field and my users will love it.

Share this post


Link to post
Share on other sites

One more thing. This may not be part of your Module but when I save a page with the Chosen Select field, I get some weird formatting. See top left of screen and specifically the UL ID of:

<ul id="notices" class="ui-widget">
<li class="ui-state-highlight NoticeMessage ui-priority-secondary NoticeDebug"><a class="notice-remove" href="#"><i class="fa fa-times-circle"></i></a><i class="fa fa-gear"></i> Session: Change: Company_Selector_2</li>

post-1166-0-04386400-1427724109_thumb.pn

I think the width here needs to be 100% and not 100px?

.ui-state-highlight.ui-state-highlight {
  top: 0;
  background: rgb(240,240,240);
  margin: 3px 5px 3px 0;
  padding: 0;
  border: 1px dotted gray;
  width: 100px;
  height: 19px;
}

Share this post


Link to post
Share on other sites

This thing is supposed to be the ghost element while drag-and-droping a tag. Congrats jQuery UI... I'll see if I can namespace this thing somehow. 

Edit: it's fixed for the dev branch. Will push it to master as soon as I've included a defaultAdminTheme.css as well. 

  • Like 1

Share this post


Link to post
Share on other sites

Is it possible to allow users to add pages by typing in something but still only show the same pages as before in the drop down?

For example I have "foo" and "bar" as pages which get shown in the dropdown. Now user1 types "lorem". So a page called "lorem" get created.

Now user1 creates a new page. The drop down should only show "foo" and "bar" and NOT "lorem".

Maybe if "lorem" would be "hidden" the drop down could exclude it... Could you add this as an option? Like: "make auto-created pages hidden to prevent them from appearing in the list"?

Share this post


Link to post
Share on other sites

While the new page is in the dropdown it should be grayed out and unselectable as it's already selected. So what's the problem with showing it? I don't think there's an easy option to to hide them as the chosen library is automatically build from a multiselect input which does not have any modifiers. I've tried to add destinct styling to new pages before and found no good way to do this.

Share this post


Link to post
Share on other sites

What I want to archive is that you have like ten constant suggestions but still can add your own tags which should be saved but not appear in the drop down list. Maybe I have to change it a little than :/

Or is there another way to archive that?

Share this post


Link to post
Share on other sites

Maybe the easiest way to solve this would be with some custom js logic, as your subselection needs to be in another selectfield as your saved values (which include added pages). Otherwise I'd look into other libraries as chosen is really trying to act like real selectfields.

Share this post


Link to post
Share on other sites

Made a small update so that InputfieldChosenSelectMultiple now respects the "Allow pages to be added" setting. Without it one cannot add tags anymore.

  • Like 3

Share this post


Link to post
Share on other sites

Thanks for this great module. It works perfectly together with my FieldtypeSelectExtOption.

I use it also with new Core Module Options. Is there any chance to provide the ability to add options via the Inputfield, like adding pages if used together with FieldtypePage? I know it is more on Ryans side to provide this in his Module. Maybe there is a possibility of an approach from your side too?

Share this post


Link to post
Share on other sites

Exactly what I am looking for. :) Since new page will be created by method renderAddable() in class InputfieldPage and not in FieldtypePage it would be maybe more on the Inputfield side to offer this feature. Especially in case of InputfieldChosenSelect it would be great to have it.

Share this post


Link to post
Share on other sites

I'm probably overlooking something basic but I can't get this to work. I've located the plugin in the modules directory - installed it on the modules page (no strikeout line any more through Input Chosen Select and Input Chosen Select Multiple). Then when I go to add a new field - but Input Chosen Multiple doesn't appear in the select box for field type.  What am I missing?  (ProcessWire 2.6.1) - jquery-1.10.2.min.js located in templates>scripts

Thanks in advance (feeling very stupid)

Share this post


Link to post
Share on other sites

It should normally add itself in the list of usable page inputfields, but could you please take a look at the module configuration of InputfieldPage if those two are in the list or not.

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 BitPoet
      As threatened in the Pub sub forum in the "What are you currently building?" thread, I've toyed around with Collabora CODE and built file editing capabilities for office documents (Libre-/OpenOffice formats and MS Office as well as a few really old file types) into a PW module.
      If you are running OwnCloud or NextCloud, you'll perhaps be familiar with the Collabora app for this purpose.
      LoolEditor
      Edit office files directly in ProcessWire
      Edit your docx, odt, pptx, xlsx or whatever office files you have stored in your file fields directly from ProcessWire's page editor. Upload, click the edit icon, make your changes and save. Can be enabled per field, even in template context.
      Currently supports opening and saving of office documents. Locking functionality is in development.
      See the README on GitHub for installation instructions. You should be reasonably experienced with configuring HTTPS and running docker images to get things set up quickly.
      Pull requests are welcome!
      Here is a short demonstration:

    • By Robin S
      An Images field allows you to:
      Rename images by clicking the filename in the edit panel or in list view. Replace images, keeping metadata and filename (when possible) by dropping a new image on the thumbnail in the edit panel. Introduced here. But neither of these things is possible in File fields, which prompted this module. The way that files are renamed or replaced in this module is not as slick as in the Images field but it gets the job done. The most time-consuming part was dealing with the UI differences of the core admin themes. @tpr, gives me even more respect for the work that must go into AdminOnSteroids.
      Most of the code to support the rename/replace features is already present in InputfieldFile - there is just no UI for it currently. So hopefully that means these features will be offered in the core soon and this module can become obsolete.
       
      Files Rename Replace
      Allows files to be renamed or replaced in Page Edit.

      Usage
      Install the Files Rename Replace module.
      If you want to limit the module to certain roles only, select the roles in the module config. If no roles are selected then any role may rename/replace files.
      In Page Edit, click "Rename/Replace" for a file...
      Rename
      Use the text input to edit the existing name (excluding file extension).
      Replace
      Use the "Replace with" select to choose a replacement file from the same field. On page save the file will be replaced with the file you selected. Metadata (description, tags) will be retained, and the filename also if the file extensions are the same.
      Tip: newly uploaded files will appear in the "Replace with" select after the page has been saved.
       
      https://github.com/Toutouwai/FilesRenameReplace
      http://modules.processwire.com/modules/files-rename-replace/
    • By d'Hinnisdaël
      So I decided to wade into module development and created a wrapper module around ImageOptim, a service that compresses and optimizes images in the cloud. ImageOptim currently handles JPG, PNG and GIF files and, depending on the settings you use, shaves off between 15% and 60% in filesize. Great for bandwidth and great for users, especially on mobile.
      This module handles the part of uploading images to ImageOptim via their official API, downloading the optimized version and storing it alongside the original image.
       

       
      Download & Info
      GitHub / Module directory / Readme / Usage
       
      Why ImageOptim?
      There are other image optimization services out there, some of them free, that have outstanding ProcessWire modules. A few things make ImageOptim the best tool for most of my customers: It's not free, i.e. it will probably be around for a while and offers support. However, it's cheaper than some of the bigger competitors like Cloudinary. And it does PNG compression better than any of the free services out there, especially those with alpha channels.
       
      Installation
      Install the module like any other ProcessWire module, by either copying the folder into your modules folder or installing it via the admin. See above for downloads links on GitHub and in the module directory.
       
      Requirements
      To be able to upload images to the service, allow_url_fopen must be set on the server. The module will abort installation if that's not the case.
      I have only tested the module on ProcessWire 3.x installations. I don't see why it shouldn't work in 2.x, if anyone wants to try it out and report back.
       
      ImageOptim account
      To compress images, you first need to sign up for an ImageOptim account. They offer free trials to try the service.
       
      Usage (manual optimization)
      Images can be optimized by calling the optimize() method on any image. You can pass an options array to set ImageOptim API parameters.
      $image->size(800,600)->optimize()->url $image->optimize(['quality' => 'low', 'dpr' => 2]) // Set quality to low and enable hi-dpi mode
      Automatic optimization
      The module also has an automatic mode that optimizes all image variations after resizing. This is the recommended way to use this module since it leaves the original image uncompressed, but optimizes all derivative images.
      $image->size(800,600)->url // nothing to do here; image is optimized automatically
      To change compression setting for single images, you can pass an options array along with the standard ImageResizer options. Passing false disables optimization.
      $image->size(800, 600, ['optimize' => 'medium']) $image->size(800, 600, ['optimize' => ['quality' => 'low', 'dpr' => 2]]) $image->size(800, 600, ['optimize' => false])
      For detailed usage instructions and all API parameters, see the usage instructions on GitHub.
       
      Filenames
      Optimized images will be suffixed, e.g. image.jpg becomes image.optim.jpg. You can configure the suffix in the module settings.
       
      Roadmap
      Asynchronous processing. Not really high on the list. Image variations need to be created anyway, so waiting a few seconds longer on first load is preferable to adding complexity to achieve async optimization. Optimize image variations created by other modules. CroppableImage comes to mind. I don't use any of these, so if somebody wants to help out and submit a pull request — all for it! Add a dedicated page in the setup menu with a dashboard and detailed statistics. ImageOptim's API is very barebones for now, so not sure if that's feasible or even necessary.
      Stability
      I've been using this module on production sites for some time now, without hiccups. If you do notice oddities, feel free to comment here or investigate and submit PRs.
    • By daniels
      General
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      It can update / create a subscriber in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe users to different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns You can find it here: https://github.com/danielstieber/SubscribeToMailchimp
      Let me know what you think and if I should add it to the Modules Directory.
      Setup
      Log into your Mailchimp account and go to  Profile > Extras > API Keys. If you don't have an API Key, create a new one. Copy your API Key and paste it in the module settings (Processwire > Modules > Site > SubscribeToMailchimp). Back in Mailchimp, go to the list, where you want your new subscribers. Go to Settings > List name and defaults. Copy the List ID an paste it in to the module settings.
      Usage
      To use the module, you need to load it into your template:
      $mc = $modules->get("SubscribeToMailchimp"); Now you can pass an email address to the module and it will try to edit (if the user exists) or create a new subscriber in your list.
      $mc->subscribe('john.doe@example.com'); You can also pass a data array, to add additional info.
      $mc->subscribe('john.doe@example.com', ['FNAME' => 'John', 'LNAME' => 'Doe']); You can even choose an alternative list, if you don't want this subscriber in your default list.
      $mc->subscribe('john.doe@example.com', ['FNAME' => 'John', 'LNAME' => 'Doe'], 'abcdef1356'); // Subscribe to List ID abcdef1356  
      Important Notes
      This module does not do any data validation. Use a sever-sided validation like Valitron Make sure that you have set up your fields in your Mailchimp list. You can do it at Settings > List fields and *|MERGE|* tags Example
      Example usage after a form is submitted on your page:
      // ... validation of form data $mc = $modules->get("SubscribeToMailchimp"); $email = $input->post->email; $subscriber = [ 'FNAME' => $input->post->firstname, 'LNAME' => $input->post->lastname, ]; $mc->subscribe($email, $subscriber);  
      Troubleshooting
      In case of trouble check your ProcessWire warning logs.
      I can't see the subscriber in the list
      If you have enabled double opt-in (it is enabled by default) you will not see the subscriber, until he confirmed the subscription in the email sent by Mailchimp
      I get an error in my ProccessWire warning logs
      Check if you have the right List ID and API Key. Check if you pass fields, that exist in your list. Check if you pass a valid email address. Go to Mailchimps Error Glossary for more Information
      How To Install
      Download the zip file at Github or clone directly the repo into your site/modules If you downloaded the zip file, extract it in your sites/modules directory. You might have to change the folders name to 'SubscribeToMailchimp'. Goto the modules admin page, click on refresh and install it  
    • By PWaddict
      Module for hiding pages for non-superusers.
      Download
      HidePages
      Requirements
      ProcessWire 3.x Changelog
      1.0.1 (31 March 2018)
      Module renamed to prevent confusion 1.0.0 (30 March 2018)
      Initial release