Hi!
I’m working on an image gallery. Each project in the gallery should contain a cover image that will be visible on the website, as well as a downloadable .png and .svg file. In order to keep my folders somewhat structured I want to have a separate folder within the project folder for the downloadable files. I tried using the ‘hooks’ method in my config.php to automatically create the holder when a new project page is created:
<?php
return [
'debug' => true,
'languages' => true,
'date.handler' => 'intl',
'home' => 'portal',
'hooks' => [
'page.create:after' => function ($page) {
if ($page->intendedTemplate() === 'data') {
$downloadsFolder = $page->root() . '/downloads';
if (!is_dir($downloadsFolder)) {
mkdir($downloadsFolder, 0755, true);
}
}
},
],
];
In my blueprint for the project page I created a separate field for uploading the downloadable files, as such:
- width: 1/2
sections:
gallery:
headline: Gallery
type: files
min: 1
layout: cards
template: image
downloads:
headline: Downloads
type: files
min: 2
layout: cards
template: downloads
root: projects/{{ page.slug }}/downloads
For some reason the directory is not being created. I also double checked that the intendedTemplate() is correct. I can’t seem to figure out where the issue lies. Any ideas?