that’s just an example I thought about and I would like to hear your opinions regarding a solution.
If for example we have a something like an event signup, where users fill out a form with their data and that data is stored in automatic created subpages, what would be the best workaround, to export the data to a pdf or a csv file (or whatever file format we would like to have)?
Using the kirby api? Creating a virtual document that can be downloaded? Create and update a file inside the event pages content folder?
At the moment, the guide and cookbook is extremely good to show examples, how we can migrate data to kirby, but not in the indirect way.
depending on your use case, creating content representations of your pages could be an idea. I often do that for pdf files with MPDF and it works quite nicely.
For example, let’s assume your registration is saved as a page with template “ticket”. In the templates folder create a “ticket.pdf.php” file containing this:
//load custom fonts
$assets = kirby()->roots()->assets();
$defaultConfig = (new ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$myFontDirs = array_filter(glob("$assets/fonts/*"), 'is_dir');
$defaultFontConfig = (new FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
//init a pdf document
$pdf = new Mpdf([
'mode' => 'utf-8',
'format' => 'A4', //adjust paper format here
'fontDir' => array_merge($fontDirs, $myFontDirs),
'fontdata' => $fontData + [
//here you can define custom fonts from your assets folder (afaik, must be ttf)
'niveaugrotesk' => [
'R' => 'ng-light.ttf', //regular
'I' => 'ng-light-italic.ttf', //italic
'B' => 'ng-bold.ttf', //bold
'BI' => 'ng-bold-italic.ttf', //bold italic
//define some CSS for your ticket layout
$css = <<<CSS
color: cmyk(0,0,0,100); /* you can use CMYK colors like this */
// capture some html to be written on the ticket
// do it like normal kirby templates
<h1>Ticket for <?= $page->name() ?></h1>
<p>Your ticket is valid for the event: <?= $page->parent()->title()->html() ?></p>
$html = ob_get_clean(); //save the captured html to this variable
//give the document a title and an author name
$pdf->SetTitle($site->title() . ' - ' . $page->title());
//write the css to the file
//write content to the file
//you can also write the HTML to a fixed box
// $pdf->WriteFixedPosHTML($html, 10, 10, 100, 100); //the numbers are the bounds of the box in mm
//respond with the pdf file
$pdf->Output($page->uid() . '.pdf', Destination::INLINE);
What happens if you remove everything from the “.pdf.php” template and just have it say “hello world” or something? This just to make sure it’s not something in the template code that causes the error.