PHP code example of presprog / kirby-auto-file-templates
1. Go to this page and download the library: Download presprog/kirby-auto-file-templates library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
presprog / kirby-auto-file-templates example snippets
// site/config/config.php
'presprog.auto-file-templates' => [
// Do nothing (default)
'autoAssign' => false,
// OR automatically assign a file template for every file type
'autoAssign' => true,
// OR only assign templates to some file types (ignore file types other than `image` and `video`
'autoAssign' => [
'image' => true,
'video' => true,
],
// OR define a specific template for just some file types and let the plugin decide for the others
'autoAssign' => [
'image' => 'my-custom-image-blueprint',
'video' => true, // => 'video'
],
// OR handle more advanced use-cases in callable yourself (assign different file templates for vector and raster images)
'autoAssign' => [
'image' => function(\Kirby\Cms\File $file) {
return match (F::extension($file->filename())) {
'svg' => 'vector',
default => 'image',
};
},
],
// Overwrite existing template assignments (default: false)
'forceOverwrite' => true,
],
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.