Kirby Sortable Field / Modules Field

Do you use the modules plugin with the following (default) config or something similar?

// UID to use when looking for the modules directory of a content page
c::set('modules.parent.uid', 'modules');

If so you need a modules page inside your page that stores the modules. Se here for reference.

From your blueprint it looks like you are using modules without a seperate directory. If so you would need to adjust the modules.parent.uid config accordingly.

Does anyone know how to flip the order of subpages displayed with the sortable plugin? Would be nice if there is an option like sort: flip as it is in the pages options.

I want to have the newest page on top. And every new created page should be listed on top.

Thanks for any hint…

If you just want to list the subpages (without all the great features of the sortable plugin) you could use the subpagelist field instead which accepts/inherits some of the page options.

The sortable field is intended to sort subpages rather than display them in a order depending on some data.

When the supagelist field does not fit your needs you could create a custom field which extends the sortable field.

Some more informations on customizing the field and some examples.

Your custom field would need to change the output of the entries method. Something like this perhaps. But keep in mind that you would lose the possibility to sort pages.

<?php

class MyCustomSortableField extends SortableField {

  public $sortable = false;

  public function entries() {
    $entries = parent::entries();
    return $entries->sortBy('date', 'desc');
  }

}

Thanks @flokosiol. At the moment I have the subpagelist in use… But the easy hide/show and the duplicate feature is really tempting.

And many thanks to @lukaskleinschmidt. I really appreciate your effort. I will have a look into this to see what I can do. If I loose the sorting possibility, that doesn’t bother me.

If you get stuck somewhere please let me know.

if I only want to display a different field than the title field of a subpage, should I go all the way and make a custom layout / template as reported in the readme? Isn’t there a simpler way?

I’m afraid there is no easier way to do this at the moment.

OK, so I correctly remembered that by using kirby sortable with kirby modules you can easily set a panel preview → https://github.com/lukaskleinschmidt/kirby-sortable/tree/master/fields/modules#preview

Sorry, I did not mention I was using kirby module with kirby sortable module extension… the kirby sortable github page is a bit overwhelming.

Actually it doen’t matter if you use the core field (type: sortable) or the extended field for the modules plugin (type: modules). You would still need to create your own layout and then use that in your blueprint.

If you need any help to set it up please let me know.

Maybe we are saying the same thing, but I simply added a template.preview.php inside site/modules/template/, using html + php and it all works :smiley:

My previous question was if I had to take this other route, which I don’t!

I installed the sortable-variant example, in order to delete the copy and paste buttons below each subpage.

How do I go to activate it?

I tried to set in the blueprint

sortable:
  [...]
  variant: true

and then in the sortable-variant folder, deleting the following lines in /field/template.php:

<?= $field->action('_paste', ['label' => $field->l('field.sortable.paste.first'), 'icon' => '', 'class' => '']); ?>
[...]
<?= $field->action('_paste'); ?>

but nothing changed. I have the feeling I haven’t activated properly the sortable-variant extension…

The sortale-variant example actually extends the sortable field and you end up with new field called variants instad of sortable.

So you would need to use it like this in your blueprints:

fields:
  sortable:
    label: Sortable
    type: variants #instead of sortable
    …

thank you! it works now.