Jump to content
Macrura

Selectize.js modules family

Recommended Posts

The JquerySelectize module, that all of the other Selectize family modules require, has been updated (to version 1.0.1) as follows:

1) Checks to see if the core version is 3.0.67 or higher (version at which selectize was added to core), and if so, will load the core files, and not this module's files.

Using the ProcessWire core versions of selectize.js improves the user experience, because of the adjustments that Ryan made to the plugin, which relates to hitting enter key after typing a tag (which would by default submit the form).

2) In addition to loading the CSS & JS from the core, when working in versions 3.0.67 or higher, the module still provides a skin selector.
While most users will probably stick to the core non-skinned version of Selectize, the module provides this option to choose a different skin. There are some scenarios where choosing the default or bootstrap skins for selectize can be preferable, as they may be higher contrast or more pronounced with color usage, and can help in some ways with accessibility for users with any type of vision impairment.

Currently the update/behavior only applies to Selectize modules family that require and use the JquerySelectize module, so if you are using core image tags and have this module installed, it won't change the skin; However there is a plan to try and hook into the image field rendering and enable this module to add the custom selected skin to the css files.

  • Like 5

Share this post


Link to post
Share on other sites

This is a status update regarding the 4 modules:

1) JquerySelectize

This module is not be required by any of the modules below, for PW versions > 3.0.66.
Latest version also allows the module css/js to be loaded instead of the core css/js - mostly for testing/debug.

2) InputfieldSelectize (and InputfieldSelectizeMultiple)

Everything seems to be working fine.

The dependency on the JquerySelectize is removed for versions > 3.0.66, and the module inits the core library when in use.
If JquerySelectize module is present/installed, then it will hand off the loading of the assets to the module, where you can then choose where to load from.

3) SelectizeImageTags

UPDATE - latest version should work now - if you use this module with any PW version > 3.0.66, please update to the latest version.

4) SelectizeTemplateFields

This works fine with the core selectize. The dependency on the jQuery module is removed for versions > 3.0.66.

  • Like 3

Share this post


Link to post
Share on other sites

@Macrura After updating to the latest version of InputFieldSelectize(1.0.3) I now get the following error when I try to view a field using InputFieldSelectize

Quote

Call to undefined function bd() in ...\InputfieldSelectize\InputfieldSelectize.module on line 266

I am running ProcessWire version 3.0.62

Share this post


Link to post
Share on other sites

sure – let me know if you run into any issues, as that new version utilizes the core selectize library;

Share this post


Link to post
Share on other sites

@Macrura Feature request:

Would it be possible to make the field refresh after page changes? In your examples, you put an editUrl that opens a modal. After making an edit in a modal, the field does not reflect the changes made. Another example is when creating new pages. I like to use PageFieldEditLinks by @thetuningspoon but after adding a page, it doesn't show up in the selectize options. Maybe this should be a feature of PageFieldEditLinks instead. It might need cooperation between you two. I believe you made the original AdminPageSelectEditLinks? I am not too sure :)

I tried making my own hacky changes to PageFieldEditLinks but it didn't work too well.

Otherwise, this is a really great module :)

Share this post


Link to post
Share on other sites

it should be possible to re-init the selectize page select when the pw-modal closes, in terms of creating a new page;
i will have to look at how the page select edit links does it, because thetuningspoon did most of the module...

Also - be careful with the editUrl if you upgrade PW past 3.0.66- there seems to be a problem when there is an anchor inside the option/item that interferes with displaying the remove button; i have not figured it out yet what the problem is there but am actively investigating it - created github issue and posted topic on the 3.0.67 topic;

EDIT - seems that maybe there is no problem, my test environment shows the remove button fine when using core version of lib...

Share this post


Link to post
Share on other sites

looks like adding new pages to the field should just be a matter of adding 2 selectors in the page field edit links module, so that it can be inclusive/aware of Selectize inputfield.

  • Like 1

Share this post


Link to post
Share on other sites
On 7/9/2017 at 8:33 PM, Robin S said:

I would say that anyone already using the module on older websites is probably happy enough with the existing functionality and should stick with v0.0.2. PW will show a warning for anyone trying to upgrade that does not meet the minimum version dependency. Not sure if the Upgrades module will actually refuse to upgrade in such a situation (I don't have an easy way to check) but you could include an additional warning advising to revert to v0.0.2:


/**
 * Upgrade
 */
public function ___upgrade($fromVersion, $toVersion) {
    // Upgrade from < v0.0.3
    if($fromVersion < 3) {
        if($this->config->version < '3.0.61') {
            throw new WireException("The minimum required ProcessWire version is 3.0.61. Please revert to Selectize Image Tags v0.0.2");
        }
    }
}

 

@Robin S i'm having some trouble with the upgrade on this, not sure what's going on, maybe related to the upgrade method?

598cf9d71efcb_Modules__ProcessWire__apps_williamanderson_us.jpg.af5b4e4944394f659413277f60913b51.jpg

 

this is on 3.0.70, so it should meet the requirements... i'll try removing the upgrade function and see if the mod requirement works

 

Share this post


Link to post
Share on other sites
26 minutes ago, Macrura said:

@Robin S i'm having some trouble with the upgrade on this, not sure what's going on, maybe related to the upgrade method?

The issue won't be related to the upgrade method because the error message is different. So it must relate to the 'requires' property in the getModuleInfo() method.

I note that above you say that JquerySelectize is not to be required.

On 09/08/2017 at 6:28 AM, Macrura said:

1) JquerySelectize

This module is not be required by any of the modules below, for PW versions > 3.0.66.

So you would want to remove that module from the 'requires' property if you haven't already, and perhaps check for it in the install/upgrade methods depending on the PW version.

Share this post


Link to post
Share on other sites

ok thanks - yeah i moved the module info into the <modulename>.info.php field and in there i add the module requires to the array by checking the config->version;

maybe there is something wrong with how i'm doing that...

$info = array(
    'title' => 'Selectize Image Tags',
    'author' => 'Macrura',
    'version' => 007,
    'summary' => 'Admin helper for enabling selectize.js on images tags field.',
    'href' => '',
    'icon' => 'tags',
    'singular' => true,
    'autoload' => 'template=admin',
    'requires'  => array(
        'ProcessWire>=3.0.61'
    )
);

if($this->wire('config')->version < '3.0.67') {
	$info['requires'][] = "JquerySelectize";
}

*Btw - i do have that module (JquerySelectize) also installed anyway, in case that matters..

Share this post


Link to post
Share on other sites
8 minutes ago, Macrura said:

maybe there is something wrong with how i'm doing that...

I've never tried setting the module info conditionally like that (or the external info.php approach), but it looks like it should work. Tracy should help here to check the resulting $info array.

  • Like 1

Share this post


Link to post
Share on other sites

it definitely works overall (when the module is already in the modules dir), but can't figure out why it fails on the upgrades download, the requires numbers look messed up...

Share this post


Link to post
Share on other sites

looks like the modules directory isn't parsing or understanding the info file:

"requires_versions":{"":[">=",0]}

http://modules.processwire.com/export-json/SelectizeImageTags/?apikey=pw300

i probably need change something in that <modulename>info.php, since the $config check needs to check the target site, not the modules website, in case the engine that creates that json page is PW..

Share this post


Link to post
Share on other sites
4 hours ago, Macrura said:

looks like the modules directory isn't parsing or understanding the info file:


"requires_versions":{"":[">=",0]}

That does look strange, but I think it might be normal. It seems to apply to all modules: http://modules.processwire.com/export-json/oauth2-login/?apikey=pw300
And if the values are blank then I would expect it not to apply any restriction.

I see that you have module info defined it two places - maybe that is the cause of the issue?
https://github.com/outflux3/SelectizeImageTags/blob/d4160b20f40e05840b6cb5d947fb63b3a95aeb4c/SelectizeImageTags.info.php#L4-L20
https://github.com/outflux3/SelectizeImageTags/blob/d4160b20f40e05840b6cb5d947fb63b3a95aeb4c/SelectizeImageTags.module#L7-L22

Share this post


Link to post
Share on other sites

that's actually inside the comment header, in case i need to put it back

Share this post


Link to post
Share on other sites
34 minutes ago, Macrura said:

that's actually inside the comment header, in case i need to put it back

Right, gotcha.

1 hour ago, Robin S said:

That does look strange, but I think it might be normal. It seems to apply to all modules: http://modules.processwire.com/export-json/oauth2-login/?apikey=pw300

Actually, this module is not installable either despite the requires property being consistent with the module documentation.

2017-08-12_112340.png.05c10ddbe7a9da310f22792eabaa8c95.png

 So I think it's an issue with ProcessModule and/or the Modules directory JSON generator and it should be reported to Ryan.

  • Like 2

Share this post


Link to post
Share on other sites

@Macrura When I set an InputfieldSelectize to required, the first value is selected. Is there any way to prevent this? I wish to have it behave as it does when not set to required, the same way that InputfieldSelect does it. This might be really dumb, but I couldn't find it mentioned anywhere.

Share this post


Link to post
Share on other sites

Hi Sipho - ok i'm not sure how the required works for single input, when you look at the source, is the source code showing the first option selected (the pw source <select> element? If that's the case then the required behavior of the field is inheriting from PW, i don't think the JS can affect that..

Share this post


Link to post
Share on other sites

@Macrura This is when using required InputfieldSelect:

<select id="Inputfield_family" class="required" name="family" tabindex="5">
  <option selected="selected" value=""></option>
  <option value="1084">Saturniidae</option>
</select>

InputfieldSelect.png.7bfbd75dd44456676fe5198d5a5f7b09.png

This is when using non-required InputfieldSelect

<select id="Inputfield_family" name="family" tabindex="5">
  <option selected="selected" value=""></option>
  <option value="1084">Saturniidae</option>
</select>

InputfieldSelect2.png.1e16e65d41adbec33fd3e0832e1e67ef.png

This is when using required InputfieldSelectize:

<select id="Inputfield_family" class="required selectized" name="family" tabindex="6" style="display: none;">
  <option value="1084" selected="selected">Saturniidae</option>
</select>

InputfieldSelectize.png.19b67e9ad94307ef4e1dbb4aea867913.png

This is when using non-required InputfieldSelectize

<select id="Inputfield_family" name="family" tabindex="6" style="display: none;" class="selectized">
  <option value="" selected="selected"></option>
</select>

InputfieldSelectize2.png.880688105dc409f3f80d212a7418123c.png

Share this post


Link to post
Share on other sites

ok thanks - will look into it asap - it is because the module is using the addOption() method which is filtering out the items with no value, guess this needs to be fixed...

Edit : testing here and it seems to be working correctly - i'm not seeing the empty option filtering out - can you tell me more about the settings on the inputfield is it set to single (not multiple pages?)

Share this post


Link to post
Share on other sites

Sorry I forgot to mention I am creating the inputfield from the API. Here is the code I am using to generate it:

<?php
$template = "family";
$label = "Family";

$f = $this->modules->get("InputfieldSelectize");
$f->name = $template;
$f->label = $label;
$f->required = true;
$f->columnWidth = 33;
$f->addOption("");
$f->set("itemDataArray", '$data = array("title" => $page->title);return $data;');
$f->set("renderOptionMarkup", "'<div class=\"item\"><span style=\"display:block;font-size:14px;font-weight:bold;\">' + escape(item.title)  + '</span></div>'");
$f->set("renderItemMarkup", "'<div class=\"item\"><span style=\"display:block;font-size:14px;font-weight:bold;\">' + escape(item.title)  + '</span></div>'");
foreach ($this->pages->find("template=".$template) as $p) {
  $f->addOption($p->id, $p->title);
}
$f->attr("value", "");
$form->add($f);

I haven't included the whole form as I don't think it's relevant.

I believe it would have to be InputfieldSelectizeMultiple for it to be set to multiple pages, so it's set to single pages. If I just change required to false, it behaves as expected. Maybe I am incorrectly using the API.

Share this post


Link to post
Share on other sites

As a tangent question, is it possible to use InputfieldSelectize for non-page inputfields? So for example, using InputfieldSelect I can say:

<?php
$f->addOption("pie","Pie");

But using InputfieldSelectize I can't seem to figure out how to get the value in the itemDataArray. Is there a way to do this?

Share this post


Link to post
Share on other sites

To answer the first question, can you try the attached module and let me know if it works;

You need to use the new method addBlankOption(); which will then add the correct data-data attribute to the option in case you want to use something like 'Please Select...';

$f->addBlankOption();

or

$f->addBlankOption('Please Select...');

This is really only necessary when using from the API because in page edit context i think the default behavior works; this does allow you to use this inputfield in modules which is cool, and have a blank option; needs more work though since the blank option json in data-data attribute will need to match the other options.. might be some time till that part is solved, but this should work for now..

InputfieldSelectize.module

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      After forgetting the class name of the wonderful AdminPageFieldEditLinks module for what feels like the 100th time I decided I needed to give my failing memory a helping hand...
      Autocomplete Module Class Name
      Provides class name autocomplete suggestions for the "Add Module From Directory" field at Modules > New.
      Requires ProcessWire >= v3.0.16.
      Screencast

      Installation
      Install the Autocomplete Module Class Name module.
      Configuration
      Choose the type of autocomplete options list: "Module class names from directory" or "Custom list of module class names". The latter could be useful if you regularly install some modules and would prefer a shorter list of autocomplete suggestions. The list of class names in the modules directory is generated when the Autocomplete Module Class Name module is installed. It doesn't update automatically (because the retrieval of the class names is quite slow), but you can use the button underneath when you want to retrieve an updated list of class names from the directory. The "fuzzy search" option uses custom filter and item functions for Awesomplete so that the characters you type just have to exist in the module class name and occur after preceding matches but do not need to be contiguous. Uncheck this option if you prefer the standard Awesomplete matching. Custom settings for Awesomplete can be entered in the "Awesomplete options" field if needed. See the Awesomplete documentation for more information.  
      https://github.com/Toutouwai/AutocompleteModuleClassName
      https://modules.processwire.com/modules/autocomplete-module-class-name/
    • By teppo
      MarkupMenu is a markup module for generating menu trees. When provided a root page as a starting point, it generates a navigation tree (by default as a HTML "<ul>" element wrapped by a "<nav>" element) from that point onwards. If you've also provided it with current (active) page, the menu will be rendered accordingly, with current item highlighted and items rendered up to that item and its children (unless you disable the "collapsed" option, in which case the full page tree will be rendered instead).
      Modules directory: https://modules.processwire.com/modules/markup-menu/ GitHub repository: https://github.com/teppokoivula/MarkupMenu Usage
      As a markup module, MarkupMenu is intended for front-end use, but you can of course use it in a module as well. Typically you'll only need the render() method, which takes an array of options as its only argument:
      echo $modules->get('MarkupMenu')->render([ 'root_page' => $pages->get(1), 'current_page' => $page, ]); Note: if you omit root_page, site root page is used by default. If you omit current_page, the menu will be rendered, but current (active) page won't be highlighted etc.
      A slightly more complex example, based on what I'm using on one of my own sites to render a (single-level) top menu:
      echo $modules->get('MarkupMenu')->render([ 'current_page' => $page, 'templates' => [ 'nav' => '<nav class="{classes} menu--{menu_class_modifier}" aria-label="{aria_label}">%s</nav>', 'item_current' => '<a class="menu__item menu__item--current" href="{item.url}" tabindex="0" aria-label="Current page: {item.title}">{item.title}</a>', ], 'placeholders' => [ 'menu_class_modifier' => 'top', 'aria_label' => 'Main navigation', ], 'include' => [ 'root_page' => true, ], 'exclude' => [ 'level_greater_than' => 1, ], ]); Note: some things you see above may not be entirely sensible, such as the use of {menu_class_modifier} and {aria_label} placeholders. On the actual site the "nav" template is defined in site config, so I can define just these parts on a case-by-case basis while actual nav markup is maintained in one place.
      Please check out the README file for available render options. I'd very much prefer not to keep this list up to date in multiple places. Basically there are settings for defining "templates" for different parts of the menu (list, item, etc.), include array for defining rules for including in the menu and exclude array for the opposite effect, classes and placeholders arrays for overriding default classes and injecting custom placeholders, etc. 🙂
      MarkupMenu vs. MarkupSimpleNavigation
      TL;DR: this is another take on the same concept. There are many similarities, but also some differences – especially when it comes to the supported options and syntax. If you're currently using MarkupSimpleNavigation then there's probably no reason to switch over.
      I'd be surprised if anyone didn't draw lines between this module and Soma's awesome MarkupSimpleNavigation. Simply put, I've been using MSN (...) for a number of years, and it's been great – but there have been some smallish issues with it, particularly with the markup generation part, and it's also doing some things in a way that just doesn't work for me – the xtemplates thing being one of these. In many ways it's less about features, and more about style.
      In MarkupMenu I've tried to correct these little hiccups, modernise the default markup, and allow for more flexibility with placeholder variables and additional / different options. MarkupMenu was built for ProcessWire 3.0.112+ and PHP 7.1+, it's installable with Composer, and I have a few additional ideas (such as conditional placeholders) on my todo list.
      One smallish and rather specific difference is that MarkupMenu supports overriding default options via $config->MarkupMenu. I find myself redefining the default markup for every site, which until now meant that each site has a wrapper function for MarkupSimpleNavigation (to avoid code / config repetition), and this way I've been able to omit that 🙂
      Requirements
      ProcessWire >= 3.0.112 PHP >= 7.1.0 If you're working on an earlier version of ProcessWire or PHP, use MarkupSimpleNavigation instead.
    • By Robin S
      Repeater Images
      Adds options to modify Repeater fields to make them convenient for "page-per-image" usage. Using a page-per-image approach allows for additional fields to be associated with each image, to record things such as photographer, date, license, links, etc.
      When Repeater Images is enabled for a Repeater field the module changes the appearance of the Repeater inputfield to be similar (but not identical) to an Images field. The collapsed view shows a thumbnail for each Repeater item, and items can be expanded for field editing.
      Screencast

      Installation
      Install the Repeater Images module.
      Setup
      Create an image field to use in the Repeater field. Recommended settings for the image field are "Maximum files allowed" set to 1 and "Formatted value" set to "Single item (null if empty)". Create a Repeater field. Add the image field to the Repeater. If you want additional fields in the Repeater create and add these also. Repeater Images configuration
      Tick the "Activate Repeater Images for this Repeater field" checkbox. In the "Image field within Repeater" dropdown select the single image field. You must save the Repeater field settings to see any newly added Image fields in the dropdown. Adjust the image thumbnail height if you want (unlike the core Images field there is no slider to change thumbnail height within Page Edit). Note: the depth option for Repeater fields is not compatible with the Repeater Images module.
      Image uploads feature
      There is a checkbox to activate image uploads. This feature allows users to quickly and easily add images to the Repeater Images field by uploading them to an adjacent "upload" field.
      To use this feature you must add the image field selected in the Repeater Images config to the template of the page containing the Repeater Images field - immediately above or below the Repeater Images field would be a good position.
      It's recommended to set the label for this field in template context to "Upload images" or similar, and set the visibility of the field to "Closed" so that it takes up less room when it's not being used. Note that when you drag images to a closed Images field it will automatically open. You don't need to worry about the "Maximum files allowed" setting because the Repeater Images module overrides this for the upload field.
      New Repeater items will be created from the images uploaded to the upload field when the page is saved. The user can add descriptions and tags to the images while they are still in the upload field and these will be retained in the Repeater items. Images are automatically deleted from the upload field when the page is saved.
      Tips
      The "Use accordion mode?" option in the Repeater field settings is useful for keeping the inputfield compact, with only one image item open for editing at a time. The "Repeater item labels" setting determines what is shown in the thumbnail overlay on hover. Example for an image field named "image": {image.basename} ({image.width}x{image.height})  
      https://github.com/Toutouwai/RepeaterImages
      https://modules.processwire.com/modules/repeater-images/
    • By EyeDentify
      Hello There Guys.

      I am in the process of getting into making my first modules for PW and i had a question for you PHP and PW gurus in here.

      I was wondering how i could use an external library, lets say TwitterOAuth in my PW module.
      Link to library
      https://twitteroauth.com/

      Would the code below be correct or how would i go about this:
      <?PHP namespace ProcessWire; /* load the TwitterOAuth library from my Module folder */ require "twitteroauth/autoload.php"; use Abraham\TwitterOAuth\TwitterOAuth; class EyeTwitter extends WireData,TwitterOAuth implements Module { /* vars */ protected $twConnection; /* extend parent TwitterOAuth contructor $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret); */ public function myTwitterConnection ($consumer_key, $consumer_secret, $access_token, $access_token_secret) { /* save the connection for use later */ $this->twConnection = TwitterOAuth::__construct($consumer_key, $consumer_secret, $access_token, $access_token_secret); } } ?> Am i on the right trail here or i am barking up the wrong tree?
      I don´t need a complete solution, i just wonder if i am including the external library the right way.
      If not, then give me a few hint´s and i will figure it out.

      Thanks a bunch.

      /EyeDentify
    • By dimitrios
      Hello,
      this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
      To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
      Minimum Required Facebook App configuration:
      on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version (has been tested up to v3.3), add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "http://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
      Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
      Usage
      edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
       
      Download
      PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost   Note: Facebook SDK for PHP is utilized.


×
×
  • Create New...