Comments (7)
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.
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.
You could also hide the _modules subpage in the panel sidebar-list:
.sidebar-list a[data-helper="_modules"] {
display: none;
}
from kirby-sortable.
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.
This is a much better approach. I forgot, that _modules is a page, which can be hidden. Perfect, thx!
from kirby-sortable.
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.
Will do that.
from kirby-sortable.
Related Issues (20)
- Inline editing of modules HOT 1
- Make readme more clear
- Multilang titles in module overview HOT 3
- Drag axis HOT 3
- Easier way of disabling default actions HOT 6
- Disable field when readonly is set to true in the blueprint HOT 1
- Error 500 on update if status:false in child's blueprint HOT 2
- Long module titles break the layout HOT 1
- Copy Page / recursively endless spinn HOT 3
- Skipping modal (hacky solution) HOT 3
- Error on pasting modules using the Modules field HOT 1
- Add page title for new entries HOT 1
- Role based actions in layouts HOT 2
- Drag and Drop not working in IE 11 HOT 2
- Disable sorting based on roles HOT 5
- Hide page in module section HOT 8
- Error: mb_strpos(): Empty delimiter HOT 8
- in the add modal are modules and page templates shown mixed HOT 1
- Rename modules & update blueprint in filestructure HOT 2
- PHP 7.4.x and Kirby 2.5.13 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kirby-sortable.