The changeTemplate workflow

I think I found a solution by using a helper plugin to automatically generate the create: and changeTemplate arrays:

# site/plugins/kirby-modulehelper

$blueprints = [];
foreach (kirby()->blueprints() as $blueprint) {
	if(Str::startsWith($blueprint, "module.")) $blueprints[] = $blueprint;
}

Kirby::plugin('medienbaecker/modulehelper', [
    'blueprints' => [
        'modulehelper/create' => [
			'create' => $blueprints
		],
		'modulehelper/changeTemplate' => [
			'changeTemplate' => $blueprints
		]
    ]
]);

Using this plugin I can shorten my pages section…

modules:
  type: pages
  parent: page.find("modules")
  extends: modulehelper/create

…and module blueprints:

title: Quote
options:
  extends: modulehelper/changeTemplate

It seems to work great (and I’m quite a bit proud of it).
There’s only one issue: you can’t extend in an extend. That means it’s not possible to outsource the modules pages section and extend the modulehelper.

2 Likes