Where have you installed the plugin?
I removed the previous version from ā/site/fieldsā and added the plugin to ā/site/pluginsā as the documentation told.
S.
The folder must be named modules-field
not field-modules
. Probably wasnāt the best idea to switch the names. But it looks better with the modules
plugin installed
Iāll try to make this more clear in the documentation.
Yeah, it works again!
Stupid meā¦ didnāt followed the docs 100%. There is the correct name.
Thank you very much! Great plugin!
S.
Idea for the next update: show used template name as ātooltipā while mouse is over the module icon in the list.
would be great!
best regards,
Sven
I like the idea. I added this to my todo-list
v2.1.0
Added support for v1.3.0 of the Modules Plugin.
Please remember to also update the field when updating the Modules Plugin
Oh, I didnāt even know that your field depends on internal methods of the plugin. Thank you for your fast update!
(and PS: Iām pretty sure the structure will now be stable for a while. ;))
Thanks so much for the Kirby Modules Field, @lukaskleinschmidt. I used it in a lot of recent projects, v2.0.0 is super useful!
I already added a comment to the ārecommended setupā issue about the following.
The subpage builder does not create the modules container when changing the template, only when creating a new page. This is only possible with a hook. I wonder if it would make sense to include the following plugin/hook I just wrote in your Modules Field plugin:
Maybe with an additional option that enables/disables this functionality for anyone not using a modules container. Although I think it doesnāt really make sense to use modules in the same folder as the pages, the sorting gets messed up anyway.
While being more user friendly when changing the template, this also makes it possible to delete pages with modules in the panel as long as the subpage deletion issue persists by switching the template. I set the force
variable of ->delete()
to true
for that.
What do you think?
Thanks for your suggestion. Sounds like a good addition. I will definitely have a closer look at this when i find the time. Especially the deletion issue bugs me and it would be nice to get around this until it is resolved in the core.
We are evaluating your plugin for a project. It works really good but we have a question regarding the modules showing up under the subpages field in the sidebar. We would like to hide all the modules in the sidebar and only keep the real subpages to keep it clean and simple for our client.
We have tested Kirby Modules Plugin with the two approaches mentioned here. With the option 2 we can hide the modules using CSS: [data-helper="_modules"] { display: none; }
Do you think this is the best approach to hide modules from the sidebar in the latest version of Kirby Modules Field? Or do you have a better solution? Are you planning to have it as an option, e.g. in the blueprint, in future releases?
You will have to hide the _modules
page from the sidebar and the breadcrumb. Using hide: true
in the modules.yml
it will be hidden from the sidebar:
title: Modules
hide: true
(...)
```
Since you can edit the subpages of this page you will also have to hide it in the breadcrumb menu on the top like this:
```
.breadcrumb-link[title="_modules"] {
display: none;
}
```
Thatās also a nice way to do it. Thanks @thguenther!
The way @thguenther mentions would be the preferred way.
One thing I want to add. If you delete a module on their respective panel page you get redirected to the parent _modules
page. I have a field which redirects any user who happens to get to the container page (_modules
) by any redirect one additional page up to reduce confusion for the client.
Not necessary for every client
Thank you for telling about it.
Iām interested in how you redirect to the parent parent page with a field. In which file are you declare the redirect for this to work and how?
The redirection is done by the Modules plugin itself. This field depends on that plugin.
The Modules plugin has a default template:
<?php
// Redirect to the page where the module appears
go($page->page());
If you add template file (e.g. templates/module.post.php
) it will be used instead of the template above.
EDIT: Sorry, didnāt noticed you asked about redirection with fields.
This is the code I use to redirect in my blueprints.
site/fields/redirect/redirect.php
.
class RedirectField extends BaseField {
public $redirect;
public function template() {
$redirect = $this->redirect();
if(is_null($redirect)) {
return go(purl($this->page()->parent(), 'edit'));
}
$page = panel()->page($redirect);
if(is_null($page)) {
return go(purl());
}
return go(purl($page));
}
}
Now you can use type: redirect
in your modules blueprint.
fields:
redirect:
label: Redirect
type: redirect
Edit:
The modules plugin only handles redirects for the frontend.
Superb support and community in this forum. Thanks a lot!
4 posts were split to a new topic: Redirect with field does not work with modules blueprint set to hide: true
I just noticed that you in the instructions say:
Bare in mind that you should not use
modules
for the field key. This might be tempting, given the purpose, but will produce an error in the panel. Use something likemodules_field
or any other key you feel comfortable with.
I realize that I use the field key modules
but have not run into any error yet. Should I change the key name anyway? What kind of error can this create?