Multiselect field

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 !

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 ?>

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 ?

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 !

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(); ?>

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

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)
4 Likes

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.

Yes, that may be. You should always use the latest beta anyway, because that’s the latest state that will become the final version eventually. Testing with it helps us to find additional bugs if you report them.

You can use a workaround by querying an JSON API where you store the site users: https://getkirby.com/docs/cheatsheet/panel-fields/select

Looks like a core field. The closest core alternative would probably be checkboxes.

The search would be helpful even with a standard select, for when the list gets a bit long.

First off, this is a great plugin, one of my favourites! :thumbsup:

Would it be possible to manually order the output of your selection from within the plugin or am I dreaming?

Thanks for great plugin!
What if I want change order of selected items?

1 Like

Currently no support for manually changing the order. It always follows the order as setup in the blueprint.

Thanks for fast reply :clap:

1 Like

I want to use it as classic select, because I have long options list and I need search functionality.
Is it possible restrict number of selected items?

Thanks a lot!

1 Like

Not yet, but I added it as a feature request for version 3 (which will be the rewrite for Kirby v3): https://github.com/distantnative/field-multiselect/issues/25

2 Likes

Really a great and elegant custom select field, thank you.

1 Like

Hmm… under Kirby2.5.5 i just got this with your demo blueprint:

Exception
The field class is missing for: field-multiselectfield at
      if(!class_exists($classname)) {
        throw new Exception('The field class is missing for: ' . $classname);
      }

EDIT:

WHOOOPS… my fault: i’ve copied it to “fields” and not to “plugins”. works now.
Thx for the plugin! :slight_smile:

1 Like