Multiselect field

panelfield
select
multiple

#1

As part of some other improvements, I felt the need for a multiselect field in Kirby and gave it a try.

It’s at the point where it seems to work, but I would appreciate more people actually testing it to find all the small (and hopefully not bigger) issues still existing with it. Would help a lot - and maybe it’s also something for you :smile: Feedback is highly appreciated!

You can find it here: https://github.com/distantnative/field-multiselect

Install it by copying the files to site/plugins/field-multiselect/.

And use it in your blueprint as follows:

bestband:
    label: Best Band Ever
    type: multiselect
    required: true
    options:
      1d : 1Direction
      bb: BBoys
      aq: Aqua
      vb: Vengaboys
      fr: Freiheit
      o3: OH!O
      mi: Miley
      bi: Bieber
      u2: U2

It can also be used with the usual field options (pages etc.) of the checkboxes field.


Multiple user roles
#2

I think we have to talk about your taste in music, but the field looks really nice!! :slight_smile:


#3

Looks cool! can one use it with a query? to fetch categories for example?


#4

Yes, you can. It works exactly the same as for the checkboxes field: http://getkirby.com/docs/cheatsheet/panel-fields/checkboxes

Oh and also a music bit for today: https://www.youtube.com/watch?v=Y7sVoZcSKdc :wink:


#5

Just uploaded a bigger update: the JS is rewritten to make it easier to understand and cleaner in general.

But more important: options are now inserted at the right position when checked. Before they were simply added to the end and on save everything would jump around, now they stay where they are, cause they get already inserted at the right place :smile:


#6

Multiselect Field for Kirby CMS

Moral Licenses also for the Multiselect field. If you are using the field and it helps you with your work, get one and share a few bucks: https://gumroad.com/l/kirby-multiselect :wink:


#7

Definitely this field is very helpful, is possible to add a search field in order to filter very long lists?


#8

Version 1.1 released

Main feature: Search filter for option (as wished for by @fenixkim)

Download: https://github.com/distantnative/multiselect | Would appreciate some support - get a moral license: https://gumroad.com/l/kirby-multiselect

multiselect


#9

OMG!!! You’ve made me so very happy now!!


#10

Thanks @distantnative.
I’ve got an Vengabus earwig now.

But great plugin for choosing categories for blogposts.

Can you tell me what the options readonly, yaml and reload are doing?


#11

Haha, great! :wink:

All those options are not really relevant for any everyday use. Readonly should make the field not editable, yaml saves the selected options in a YAML-style list instead of a string with commas as separators. And reload triggers a page reload on a selection change.

All of them originated when I tried to prepare the field as a possibility to use for multiple user roles in the panel – probably I should remove them from a next version of the plugin. Can’t see any value for them in a normal everyday use case scenario.


#12

Yeah, me neither :smile:

Btw: the vengabus is coming and everybody’s jumping … arg! Kill me now!


#13

Hi There,

Tanks a lot for your plugin, seems the perfect tool for a user to select pages in the panel too !

I m strugling to get it working as needed. Does someone know how can i retreive the link + the title of the page from the call with the multiselect in my template ?

As suggested, for the moment I m retreiving pages in my template following the checkbox model :

in my blueprint

rel_articles:
 label: Articulos relacionados
 type: multiselect
 search: true
 options: pages

And in my template

    <?php foreach($page->rel_articles()->split() as $category): ?>
<h5><?php echo html($category) ?></h5>
      <?php endforeach ?>

For the moment, i m just retreiving the URL as a value from the multiselect…But I really how no clue on how to insert a link to each page and the title of the page with the multiselect field…

Thanks a lot in advance !


#14

Should work with:

<?php foreach($page->rel_articles()->split() as $category): ?>
  <h5><a href="<?php echo page($category)->url() ?>"><?php echo page($category)->title() ?></a></h5>
<?php endforeach ?>

#15

Thanks for your quick reply
Mmm, I m getting the following error with this…

Call to a member function url() on boolean

I tried many things but not succeding…

 <h5><a href="<?php echo url($category) ?>"><?php echo html($category) ?></a></h5>

Got me close to get the link working but url() is not getting the parents and grand parents of the page…

Wouldn’t be depending on the way the value is saved in the .txt file ?


#16

Well, I guess it s actually not possible as pages are retreived as checkbox values.
Or i m I wrong ?
If anyone has a clue, it would be really appreciated !


#17

What do you get in your content file? Just the UID or the complete path? If it’s just the UID you would have to use

<?php echo $site->index()->findBy('uid', $category)->url(); ?>

#18

I m geeting the UID in the content file. And your solution works perfectly ! Thanks a lot for the help !


#19

Version 2.0.0

I just released an update of the Multiselect field and bumped up the version number to 2.0.0. As the version number suggests, this update changes a few things that can break current setups. You can find it at https://github.com/distantnative/field-multiselect

Main changes are full keyboard support and that I restructured the field to be delivered as it plugin (which requires Kirby 2.3 - currently in beta). It goes into site/plugins/field-multiselect/. The plugin then registers the field. With the new registry in Kirby 2.3, I believe all third-party elements like fields, snippets, blueprints etc. should also be delivered wrapped as a plugin. This enables us to keep only custom elements that are rather specific to the project in site/fields, site/tags etc.

Changlog

  • Requires Kirby 2.3.0
  • Renamed to field-multiselect (required renaming repository)
  • Full keyboard support added (up & down arrows)
  • Rewritten as plugin that registers the multiselect field
  • Restructured CSS as SCSS (using gulp)
  • JS improvements (and uglified via gulp)
  • Updated package.json (supports the Kirby CLI)

503 error when edit page
#20

Just one quick note and a question:

The Multiselect field / plugin seems to have display problems with Kirby 2.3.0 Beta 1 – Beta 2 works fine. Just in case somebody wonders.

My question: Is it possible to query users? I would say no, since querying is only possible for files and pages. But at least I wanted to have asked.