Giter Site home page Giter Site logo

Comments (7)

medienbaecker avatar medienbaecker commented on May 28, 2024 2

I recently noticed that the subpage builder does not build the modules container when changing the template of a page instead of creating a new one.

So when using the approach mentioned by @lukaskleinschmidt you should also add the following hook to your config.php:

kirby()->hook('panel.page.update', function($page) {
  if ($page->template() == "default" AND !$page->children()->has('modules')) {
    $page->children()->create('modules', 'modules', array(
    	'title' => '_modules'
    ));
  }
  elseif($page->children()->find("modules")) {
    $page->children()->find("modules")->delete(true);
  }
});

This creates the modules page automatically when the page uses the default template and gets updated. This also triggers when the template is changed. When the page uses another template, the modules page gets deleted.

You'll have to change the template name(s) according to your setup.

from kirby-sortable.

lukaskleinschmidt avatar lukaskleinschmidt commented on May 28, 2024

You can actually use both approaches. The field will check weather you used option 1 or option 2.
Personally i like the second approach more because it is a cleaner in the content folder. Especially when you have subpages on top of the modules.

The field should always be initiated in the blueprint of the page.

Option 1

site/blueprints/default.yml

title: Default
pages:
  template:
    - module.text
    - module.gallery
fields:
  title:
    label: Title
    type: text
  modules:
    label: Modules
    type: modules

Option 2

site/blueprints/default.yml

title: Default
pages:
  template: default
  build:
    - title: _modules
      uid: modules
      template: modules
fields:
  title:
    label: Title
    type: text
  modules:
    label: Modules
    type: modules

When you use option 2 i would recommend adding the modules field to the site/blueprints/modules.yml as well. This is because the subpage that contains the actual modules is accessible in the panel. You could also use Gloabal Field Definitions so you don't have to duplicate the field.

site/blueprints/modules.yml

title: Modules
pages:
  template:
    - module.text
    - module.gallery
fields:
  title:
    label: Title
    type: text
  modules:
    label: Modules
    type: modules

A different approach could be to hide the panel breadcrumb with a custom panel.css.
Something like that.

.breadcrumb-link[title="_modules"] {
  display: none;
}

At the moment without the field when I create a new page it then creates a folder "_modules" and then I open that folder, and then add another "page" choose the template and then fill in the content.

The above workflow does seems a little complicated, but I can just about get my head around it and what is actually happening. But the idea of a "page within a page within a page" is not something I would want or expect a client to have to deal with.

That is the main reason why i created this field so the client is able to manage modules on the page where they actually appear.

Hope i was able to answer some of your questions. Please let me know when i missed something.

from kirby-sortable.

seehat avatar seehat commented on May 28, 2024

You could also hide the _modules subpage in the panel sidebar-list:

.sidebar-list a[data-helper="_modules"] {
  display: none;
}

from kirby-sortable.

lukaskleinschmidt avatar lukaskleinschmidt commented on May 28, 2024

Thats correct. Also i would recommend using the hide option for that.

title: Modules
pages:
  template:
    - module.text
    - module.gallery
hide: true
fields:
  title:
    label: Title
    type: text
  modules:
    label: Modules
    type: modules

I think there should be some kind of demo or example configuration. I try to put something together.

from kirby-sortable.

seehat avatar seehat commented on May 28, 2024

This is a much better approach. I forgot, that _modules is a page, which can be hidden. Perfect, thx!

from kirby-sortable.

digiltd avatar digiltd commented on May 28, 2024

Thanks, some great advice.

@lukaskleinschmidt Can I suggest an change to the first line "This field was built to extend Kirby Modules Plugin by providing a more user friendly interface to the plugin." as "built on top of" suggests it might be a forked version or was inspired by.

Thanks again.

from kirby-sortable.

lukaskleinschmidt avatar lukaskleinschmidt commented on May 28, 2024

Will do that.

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.