LostKobrakai

Module
InputfieldChosenSelect

68 posts in this topic

Thanks LostKobrakai,  I was trying to make it work with a Text Field instead of a Page Field. :-[  Working like a charm and I love it.  Thanks again.

Share this post


Link to post
Share on other sites

# Small Note
Installing the module via Somas ModulesManager (Lightbox) will only install InputfieldChosenSelect but not InputfieldChosenSelectMultiple. Would be helpful to have a note in the description and/or the error note (if InputfieldChosenSelect is selected for a multi Page Field) that this should be done manually.

Share this post


Link to post
Share on other sites

Updated the module with a newer chosen release (security related) and fixed the hardcoded admin location in the warning about wrongly configured fields.

@kixe

There's already a warning if you're using a multi-page field with the wrong inputfield (because it changed from the first versions of the module). I've added a note about installing it beforehand. But there's also no * in the inputfield select for the field, which should indicate that the inputfield is not meant to be used for a multi page field.

1 person likes this

Share this post


Link to post
Share on other sites

@LostKobrakai - see issue here: https://processwire.com/talk/topic/13164-http-error-500-when-opening-some-template-pages/

Described issue happens when script reaches allowed memory limits. I guess it is because ChosenSelect fails to handle too much pages (20000 pages in m case). Anyway, when I've changed inputfield to PageAutocomplete - issue dissapeared.

Share this post


Link to post
Share on other sites

That's expected. The chosen library was created to be a seemless enhanced select field (meaning it will be fully useable without js), which is why it does not have any ajax capabilities and therefore has the same problem as all other non ajaxy inputfields when loading a ton of pages.

1 person likes this

Share this post


Link to post
Share on other sites

Just a heads up that the newest version (ProcessWire 3.0.22 devns) breaks some things, one of which is module settings fields on some modules, this being one of them (the Placeholder Text field will not save any value). (Still looking into the cause and hope to discover fix soon as it also affects my inputfield modules).

**This is now fixed in 3.0.23 devns**

Edited by Macrura
issue resolved
2 people like this

Share this post


Link to post
Share on other sites

thank you lostkobrakai, awesom module!

suggestion: could you add a css rule that hides the select input right from the beginning? it is hidden afterwards via jquery anyhow but as long as it is visible it leads to some ugly display of the unstyled select field.

do you understand what i mean? :)

Share this post


Link to post
Share on other sites

Chosen is a progressive enhancement for the plain select, which is why it doesn't do anything to the select until it's started by javascript. That behaviour is on purpose.

Share this post


Link to post
Share on other sites

hi lostkobrakai,

i think you didn't get me... see this screencast. i think it is much nicer to hide the select via css (after the reload) than having it show up and hide it afterwards:

chosen.gif

anyhow... if you do not like this enhancement i'll just leave my line css in place. but i don't see a reason not to add this by default for every chosen input field

#Inputfield_my_chosen_select { display: none; }

 

Share this post


Link to post
Share on other sites

I fully understand. Hiding the select essentially means the input is unusable if javascript does not work for whatever reason. That's exactly what you want to prevent with any progressive enhancement. It's true, that in the context of the backend it might not be a pressing issue, but I'm not really convinced that showing nothing before js kicks in is much better than showing the original select field. There will always be a layout update.

Share this post


Link to post
Share on other sites

Well you could hide with CSS add a CSS animation to unhide after a few seconds, which would ensure the select to be visible (in theory). Because of the few seconds delay the JavaScript will probably make changes to the DOM so the original select won't be visible. I've used this tecnhique in a site with a loader, to remove the loader even if there's something with JavaScript.

Anyway, I think this kind of FOUC doesn't matter too much in an admin.

1 person likes this

Share this post


Link to post
Share on other sites

I'm not sure if it works correctly, but by a quick glance in the code FieldtypeSelectExtOptions should let you choose InputfieldChosenSelect if installed.

2 people like this

Share this post


Link to post
Share on other sites
20 hours ago, LostKobrakai said:

I'm not sure if it works correctly, but by a quick glance in the code FieldtypeSelectExtOptions should let you choose InputfieldChosenSelect if installed.

Nice, I am installing the module right now!

How come it cames in 2 separates modules? I see  InputfieldChosenSelect and InputfieldChosenSelectMultiple in my new modules list.

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 VirtuallyCreative
      Hello PW Community,
      I'm trying to modify a small module I found to pull in Gravatars but I'm having a bit of an issue and was curious if someone has already done a Gravatar implementation, or could look over the module code? It installed no problem, but when I try to use it, nothing works.
      Here is the full module:
      <?php /** * Module for generating Gravatar URLs for ProcessWire users. * * Use it like this: * * Get URL only with all defaults: * $user->gravatar() * * Get image tag with different size: * $user->gravatar(array('img' => true, 's' => 200)); * */ class Gravatar extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Gravatar', 'version' => 1, 'summary' => 'Gravatar hook for users', 'singular' => true, 'autoload' => true, 'icon' => 'smile-o', ); } public function init() { $this->addHook('User::gravatar', $this, 'methodGravatar'); } public function methodGravatar($event) { $u = $event->object; if ( ! $u instanceof User) $event->return = false; return; if ( ! $u->email) $event->return = false; return; $params = ($event->arguments(0) ? $event->arguments(0) : array()); // Default options $defaults = array( 's' => 100, 'd' => 'retro', 'r' => 'g', 'img' => false, 'attrs' => array(), ); $opts = array_merge($defaults, $params); extract($opts); $url = '//www.gravatar.com/avatar/'; $url .= md5(strtolower(trim($u->email))); $url .= "?s=$s&d=$d&r=$r"; if ($img) { $url = '<img src="' . $url . '"'; foreach ($attrs as $key => $val ) { $url .= ' ' . $key . '="' . $val . '"'; } $url .= ' />'; } $event->return = $url; } } The issue is when I use $user->gravatar() I'm getting back "unknown". I know that the email being used by the current logged-in user (me) does have a Gravatar, but I'm unable to get the URL so I can place it into my template markup.
      Any insight or direction would be appreciated. I did a search for Gravatar modules / forum topics but it mostly appears to be linked to the Blog profile that uses Gravatar, not a stand-alone module / implementation.
      Regards,
      VirtuallyCreative
    • By cosmicsafari
      Hi All,
      Fairly new to ProcessWire so apologies if this is a daft question, but I am having a go creating my first module. I have set it up and enabled it as per the docs.
      However I have created another class within the same module directory, which was going to be used in the main module file but I can't get it to work for the life of me and I believe its due to me not fully understanding the namespace side of things.
      Example:
      MyModule.module.php
      <?php namespace ProcessWire; class MyModule extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Test Module', 'version' => 1, 'summary' => 'Test module', 'href' => '', 'singular' => true, 'autoload' => true, 'icon' => 'exchange', ); } public function newMethod( $testMessage ) { $foo = new Foo($testMessage); $foo->getFoo(); } } Foo.php
      <?php namespace ProcessWire; class Foo { protected $foo; public function __construct($foo) { $this->foo = $foo; } public function getFoo() { return $this->foo; } } Now as I understand it both these files should exist under the ProcessWire namespace, so in theory I should be able to use Foo within MyModule without any use statements as they both exist at the same level within the ProcessWire namespace?
      However when I try something like so:
      $myModule = $modules->getModule('MyModule'); $myModule->myMethod('Foo'); I would have thought this should return 'Foo', however I keep running into errors like:
      Any help would be appreciated.
    • By Max Allan Niklasson
      Hi, I think this is my first topic, even though I've been working with PW a few years. But now, I'm trying to restructure my way of coding, cause many templates (like activities for birding societies) are re appearing in multiple different websites. Since this, I've been working on redo this into a module, but as far as I have read I cannot store the templates (related to specific module) in the module's folder. It has to be in the templates folder?
       
    • By kongondo
      Menu Builder
       
      Modules Directory
      Project Page
      Read Me (How to install, use, etc..)

      If you want a navigation that mirrors your ProcessWire page tree, the system allows you to easily create recursive menus using either vanilla PHP or Soma's great MarkupSimpleNavigation. In some cases, however, you may wish to create menus that:
      1. Do not mirror you site's page tree (hirarchies and ancestry); and
      2. You can add custom links (external to your site) to.

      That is primarily where Menu Builder comes in. It is also helpful if you:
      3. Prefer creating menus via drag and drop
      4. Have a need for menus (or other listings) that will be changing regularly or that you want to allow your admin users to edit.

      The issue of custom menus is not new here in the forums. The difference is that this module allows you to easily create such menus via drag and drop in the Admin. Actually, you can even use it to just create some list if you wanted to. In the backend, the module uses the jQueryUI plugin nestedSortable by Manuele J Sarfatti for the drag and drop and is inspired in part by the WP Custom Menu feature.
       
      Please read the Read Me completely before using this module. 
      For Complex or highly-customised menus, it is recommended to use the getMenuItems() method as detailed in this post.
       
      Features
      Ability to create menus that do not mirror your ProcessWire Page Tree hierarchy/structure Menus can contain both ProcessWire pages and custom links Create menu hierarchies and nesting via drag and drop Easily add CSS IDs and Classes to each menu item on creating the menu items (both custom and from ProcessWire pages) or post creation. Optionally set custom links to open in a new tab Change menu item titles built from ProcessWire pages (without affecting the original page). E.g. if you have a page titled 'About Us' but you want the menu item title to be 'About' Readily view the structure and settings for each menu item Menus stored as pages (note: just the menu, not the items!) Menu items stored as JSON in a field in the menu pages (empty values not stored) Add menu items from ProcessWire pages using page fields (option to choose between PageAutocomplete and AsmSelect [default]) or a Selector (e.g. template=basic-page, limit=20, sort=title). For page fields, you can specify a selector to return only those specified pages for selection in the page field (i.e. asm and autocomplete) For superusers, optionally allow markup in your menu titles, e.g. <span>About</span> Menu settings for nestedSortable - e.g. maxLevels (limit nesting levels) Advanced features (e.g. add pages via selector, menu settings) currently permissible to superadmins only (may change to be permission-based) Delete single or all menu items without deleting the menu itself Lock down menus for editing Highly configurable MarkupMenuBuilder - e.g. can pass menu id, title, name or array to render(); Passing an array means you can conditionally manipulate it before rendering, e.g. make certain menu branches visible only to certain users [the code is up to you!]  Optionally grab menu items only (as a Menu object WireArray or a normal array) and use your own code to create custom highly complex menus to meet any need. More... In the backend, ProcessMenuBuilder does the menu creation. For the frontend, menus are displayed using MarkupMenuBuilder.

      Credits

      In this module's infancy (way back!), I wanted to know more about ProcessWire modules as well as improve my PHP skills. As they say, what better way to learn than to actually create something? So, I developed this module (instead of writing PW tutorials as promised, tsk, tsk, naughty, naughty!) in my own summer of code . Props to Wanze, Soma, Pete, Antti and Ryan whose modules I studied (read copied ) to help in my module development and to Teppo for his wonderful write-up on the "Anatomy of fields in ProcessWire" that vastly improved my knowledge and understanding of how PW works. Diogo and marcus for idea about using pages (rather than a custom db table), onjegolders for his helpful UI comments, Martijn Geerts, OrganizedFellow, dazzyweb and Mike Anthony for 'pushing me' to complete this module and netcarver for help with the code.
       
      Screens

    • By kongondo
      Introducing Variations, an Input- and Fieldtype for product variations and their attributes.
      Product variations is a topic that has been coming up now and then, especially in the recent past.  This module seeks to fill this gap. Though it's in its early stages of development, it is already functional and can be used as is. I decided to make an early announcement (modules development forum) in order to get early feedback from potential users. 
      The module is an alternative take on how variations can be built for a product. Imagine the ubiquitous T-Shirt. The product could vary by ...Size, Colour, Material, etc...These variations could in turn have internal variations, i.e. attributes....so, Size [Small, Large], Colour [Red, Blue]...etc; you get the drift.
      The usual approaches to building variations have been either to use Multiple pages, Repeaters, Page Table, Table or Matrix (limited to 1x1 variations). In this module, we do it a bit differently.
      First, the variations occur not at the Field level (meaning all product pages would have the same variations and attributes for each template) but at the page level. Secondly, there are no multiple pages for each variation and/or attributes; a product is a single page. The variations and their attributes are defined by site editors at the page level. Once a variations configuration has been defined, it is applied to the page and all possible combinations are generated (i.e. the Red,Small,Cotton; Red,Large,Cotton, etc) in the Inputfield. There is no limit to the number of variations and attributes that can be defined, although you will be amazed at how quickly the combinations grow! Prices are entered for each combination when editing the page. Combinations without prices are not saved to the database. Please note that prices cannot themselves vary at the page-level. Meaning, you cannot have ONE variation configuration that has different price inputs per product in the same FieldtypeVariations field.
      The module ships with an API for outputting variation combinations in the frontend. Search, database and in-memory work as normal in the frontend. In the backend, DataTables provides a nice paginated, filterable table. Prices can be entered on any pages (of the table) without loss of data (meaning you can enter prices on page 1, scroll to page 10, enter more prices, filter or search the products table, enter more prices and finally save; no data will be lost).
      I still have a couple of ideas and plans pending but would love to hear from you, thanks.
      Below is a short video demo of the module in its current state. Things may/will change, both UI and features. Btw, the Fieldtype, although primarily targeted at commerce applications, is by no means limited to this. Other uses requiring combinations of whatever number of variables are very much within the remit of the module.
      Planned/Hoped for features
      Import/Export product variations and attributes (Excel, etc) Full integration with Padloper (I will have to  discuss with @apeisa) SKU fields for each product variation Add/Remove extra subfields, e.g. multi-currency prices (currently there is only 1 input for each product variations' price) Product variation images? Etc... Please not this module is not related to this other planned module (but it may eventually).
      Sneak Peek Demo