Giter Site home page Giter Site logo

Comments (2)

lukaskleinschmidt avatar lukaskleinschmidt commented on June 8, 2024

The bug with disappearing pages in the panel when having numeric slugs is now fixed. But I would like to note that one should be careful with using slugs starting with numbers in kirby 2 in the first place. You might run into unexpected behavior in some cases (Wrong folder name if new page starts with a number).

The other problem is not something I am able to fix properly. Actually the reason why the modules are stored in the parent .txt file is to keep the order for visible and invisible subpages in the panel and I did never rely on the stored order in the frontend.

If you rely on the stored order and need to make sure that the subpages are always in sync with the field then you would need to implement a hook on your own to do so.
Sadly there is no generic way of doing this. Something like the following might get you going:

kirby()->hook('panel.page.move', function ($page, $oldPage) {
  // the used field name
  $field = 'modules';

  // when you are using the sortable (modules) field in conjunction
  // with the modules-plugin it is relatively easy to determine
  // weather the moved page is a module or not
  // if ($page->isModule()) {
  //
  // }
  //
  // otherwise you need to somehow make sure that the moved page
  // is a module with something along this lines perhaps:
  // if (
  //   $page->intendedTemplate() === 'subTemplate' &&
  //   $page->parent()->intendedTemplate() === 'parentTemplate'
  // ) {
  //
  // }

  if ($page->isModule()) {
    $parent = $page->parent();

    // when using the parent option
    if (!$parent->{$field}()->exists()) {
      $parent = $parent->parent();
    }

    $values = $parent->{$field}()->split(',');
    $index = array_search($oldPage->uid(), $values);
    $values[$index] = $page->uid();

    $parent->update([
      $field => implode(', ', $values),
    ]);
  }
});

from kirby-sortable.

findthebug avatar findthebug commented on June 8, 2024

Problem with slug is solved in patch 2.4.1. Thanks!

from kirby-sortable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.