Hi there,
I am using a panel.page.update
hook to create a text file with all files on a page. It’s working fine so far, except the resulting images.text
file contains a bunch of unwanted strings… I am pretty unfamiliar with php file creation, so I don’t know if it’s a usual thing, but I would anyway want to remove them from the file.
Here’s what my hook inside the config looks like:
kirby()->hook(['panel.page.update'], function($page) {
$content = array();
$content[] = $page->title()->toString() . "\n" . $page->artists()->toString() . "\n";
$i = 0;
foreach ($page->images() as $image) {
$i++;
$image->rename(sprintf("%02d", $i) . '_Pina_' . substr($page->title()->toString(), 0, 25));
$content[] = $image->filename() . " — " . strip_tags($image->caption()->kirbytext()) . "\n";
}
f::write($page->root() . '/images.text',
$content
,
$append = false);
});
This is the resulting file:
a:11:{i:0;s:31:"Staged Stairs
Emanuel Rossetti
";i:1;s:48:"01_pina_staged-stairs.jpg — Installation View
";i:2;s:48:"02_pina_staged-stairs.jpg — Installation View
";i:3;s:83:"03_pina_staged-stairs.jpg — Staged Stair II, 2019, self adhesive vinyl, 270x90cm
etc.
What do these a:11:{i:0;s:31:"
mean and how to remove them? Maybe there’s an error in my hook function…
Thanks in advance!