Hello all,
In my dashboard I have a page /recettes which means recipes.
That I want to do is automatically create a folder /pdf inside a recipe subpage.
So if I create a recipe named example I would have this architecture :
content/
3-recettes/
2017021-example/
pdf/
recette.txt
I think I have to work with hooks like this :
kirby()->hook('panel.page.update', function($page) {
/**
if ( a subpage is created inside 'recettes' ) {
create the folder inside-it
}
**/
});
But I don’t really understand how it works.
If you have a tip, as always, thanks a lot !
texnixe
February 13, 2017, 1:59pm
2
You can use the subpage builder setting in your blueprint: https://getkirby.com/docs/panel/blueprints/subpages-settings#subpage-builder
As a hook;
kirby()->hook('panel.page.create', function($page) {
if($page->intendedTemplate() == 'recette') {
try {
$page->children()->create('pdf', 'template_name', array(
'title' => 'PDF',
));
} catch(Exception $e) {
echo $e->getMessage();
}
}
});
1 Like
Thanks for that !
It’s a good start but that’s why I was thinking doing it as a hook and not with the subpage builder, cause’ now I can’t delete the recipe subpage anymore without deleting the pdf one inside it first.
And I don’t want to display this one in the panel.
Is there, a good way to do it ?
I’m currently trying this : https://getkirby.com/docs/cheatsheet/page/delete
And also, now, in the content folder it looks like this :
content/
3-recettes/
example/
1-pdf/
pdf.txt
recette.txt
I lost the sorting by date on 2017021-example/
texnixe
February 13, 2017, 4:44pm
4
As far as deleting of subpages, it does not make any difference how you create the subpage, if with a hook or using the subpage builder.
If you don’t want to show the pdf folder in the panel, you can hide it using the hide option in the blueprint for the pdf page: https://getkirby.com/docs/panel/blueprints/page-settings#hide-page
But deleting of pages with subfolders is now possible with the development branch of the panel. There’s also a plugin by @lukaskleinschmidt you can use.
Yes okay, and I do hide the subpage by setting the blueprint, but I was thinking that maybe if I create empty folder without subpage in it would do it.
I will look for all that,
Thanks again !
texnixe
February 13, 2017, 4:58pm
6
You mean without the content file? You can do that, but it wouldn’t make any difference either.