Sometimes a plugin need a configurable path like \site\greatness\
.
There are at least two different ways to add a plugin path to a plugin.
- As
site.php
custom folder setup: https://getkirby.com/docs/developer-guide/configuration/folders
- As
config.php
config: https://getkirby.com/docs/developer-guide/configuration/options
Which do you prefer?
- Config in
config.php
- Custom folder setup in
site.php
- Not sure
If you want you can also add a comment on your thoughts.
Iโm not sure if I understand your question ?
Is this about adding any kind of config variables to a plugin? Or only about a custom-path-variable-for-a-plugin?
Only paths. I looked at https://github.com/getkirby-plugins/patterns-plugin#options and there directory
is added as a config value.
I think I already have made up my mind and will keep everything in the config.php
. Itโs not that the votes flooded in this time.
Best practise maybe is to only use site.php
for Kirby core folders, not for plugins.
Indeed.
As I see it, c
(as in c::set()
) is a DI container which collects all Kirby settings. (As is l
for localized strings).
For smaller plugins, you could use a convention that prefixes the setting with the plugin name so they are โnamespacedโ (as in your patterns plugin example above).
If you should have a really big plugin with loads of config options, you could roll your own DI container and bundle it with your plugin?
1 Like