💡 Allow users to disable PDF rendering by page template
I noticed your todo in the README.md.
I was wondering what the correct way to limit the plugin to specific routes would be.
I noticed that by default all routes are enabled in index.php
I can override it like this directly in the plugin, right? That will prevent accidental PDF rendering of pages that aren’t supposed to be rendered as PDF.
'routes' => [
[
'pattern' => 'receipt.pdf', <------
'action' => function () {
$page = page("receipt");
$pdf = new KirbyPdf();
$output = $pdf
->setPage($page)
->output();
return new Response($output, 'application/pdf');
}
]
],
I haven’t figure out how I can make that change through config.php – but for my case it’s fine.
I was wondering how to make this more dynamic, keeping (:all) in the pattern and then inside the action check for a blueprint setting, such as pdf: true → redirect to PDF, otherwise show original template?
I was thinking of something more generic and easier to configure, but i didn't took time to do so :/