Kirby Sortable Field / Modules Field

During development I had a bug where the method was called in the panel after a page refresh. Pretty messy because the modules plugin kicked in and printed all modules.

It seems to work fine now. Probably a development only bug. I will update the readme accordingly.

#v2.2.0-beta

On GitHub

Another big update for the modules field. It’s not finished yet but you can already get a good impression of what is possible.
With v2.2.0 I have splitted up the modules field in a more generic field named sortable. The modules field type is still in there and should work exactly like it has before.

What has changed

  • New core field type sortable
  • Own registry for variants (translations), layouts and actions
  • Easily extendable

I have added a demo branch where you can see how it works. Just copy the content of the demo branch into site/plugins/demo and you have your own demo field. For simplicity I only added some english translations.

There are still some things to do but I would be very happy to have some feedback or ideas of what is missing or can be improved.

Sadly there is no real documentation right now. But I am working on that :sweat_smile:.

Cheers
Lukas

3 Likes

That looks very promising. Thanks a lot for this!

I just added a demo field and I think I understand it. So the layout of single module entries can be totally customized, even with buttons and custom modal functions? That’s awesome :heart:

The demo field “star” button seems to add an unknown character to the title, at least in my installation:

Darn should be a star :smirk:.

But yes you can basically change everything if you want or need to.

Also you don’t necessarily need the modules plugin. At least when you build your own extended field or use the sortable field on it’s own. You can set the parent page and or a template prefix in the blueprint.

####Example for modules:

fields:
  sortable:
    label: Modules
    type: sortable
    
    parent: modules
    prefix: module.

Edit: Hopefully fixed the star in the demo branch :star:

This very week I was thinking how your plugin is perfect for managing subpages. I’ve used it for that ignoring other Modules features. I’m super excited to give the new version a try. Love the flexibility you added to it :grinning:

Thanks for doing such a great work @lukaskleinschmidt!

I just tried to find out if it is possible to have multiple modules fields in one blueprint or can I just have a single one? I think not right? Maybe you could add this to the readme.

@Andi-Lo
With the v2.2.0-beta it is now possible to have multiple field instances in one page. Right now it is not possible.

@pedroborges
I needed the functionality for product variants but also wanted to have modules at the same time :grin:. Please give it a try. And don’t worry I will add the other translations as soon as possible :wink:

1 Like

Awesome! Would like to try it out, but got some trouble installing it.

Have v2.1 running on my site and now want to try v2.2. I copied this into the folder: plugins/modules/ but will get the error in panel Method ModulesField::__toString() must not throw an exception, caught Error: Class 'KirbyModulesModules' not found so I think I have to do something differently than in the previous version?

Edit: Damn me. I got confused by the plugin “modules” and the field “modules” (yours). Now the error is gone, will see if more occurs :smiley:

@lukaskleinschmidt I’ve not used your custom field yet but I’m in need of product variants too. Could you perhaps share how that’s done with your custom field?

I wasn’t able to put something together because I got caught up updating the plugin. I will let you know when I get to it. But basically the variants are just supages that can be managed with this field.

1 Like

I need some help from some portuguese and swedish folks.

@pedroborges, @kaloja?

Some strings changed and I need help to translate those.


Help is on the way! I will send a PR tomorrow :thumbsup:

1 Like

Added missing Swedish values: https://github.com/lukaskleinschmidt/kirby-modules-field/pull/28/commits/b2b04fb00cfde1cd796decb24ed81f2454428dc8

1 Like

#v2.2.0

I’m proud to announce v2.2.0 of the modules field. To be honest it’s now called sortable. Beside the new plugin structure and the changed name there are some more goodies :slight_smile:

Features:

  • new field types sortable and redirect (of course the modules field still exists)
  • own registry to extend and change the behaviour of the field

I’m really happy how this version turned out. And hope you can pardon me the name changing :wink:.
The only thing to do when updating from v2.1 to v2.2 is to change the plugins folder name from modules-field to sortable.

Cheers Lukas

5 Likes

hello,
have changed the foldername and get this error in panel:

PHP Fatal error: Call to a member function ui() on a non-object in /home/sven/workspace/kirby/site_/site/plugins/sortable/sortable/actions/add/add.php on line 30

:frowning:

Thats odd. What kirby version are you using?

latest

Toolkit Version: 2.4.1
Kirby Version: 2.4.1
Panel Version: 2.4.1

PHP Fatal error: Call to a member function ui() on a non-object in /home/sven/workspace/kirby/site_/site/plugins/sortable/sortable/actions/add/add.php on line 30

There seems to be something wrong with the path here. There is a site_ directory in it. Is that the correct path?

yes, the path is correct.
The page works well, except the panel.

Could you please check if the content folder containing the modules is present?