lol. you are right @texnixe. i am sorry about that. it is just simple for me then.
Hrrm… when i try to add the data to the metafile via a hook, it tells me the update method is undefined…
'hooks' => [
'file.create:after' => function ($file) {
if($file = $this) {
try {
$this->update([
'artist' => $this->id3('artist'),
'year' => $this->id3('year'),
]);
echo 'The meta info has been updated';
} catch(Exception $e) {
echo 'The meta info could not be updated';
}
}
},
]
Have i missed something? Also can I have different file blueprints for different file types? Im getting data for the focus plugin on audio files. Id like to do different fields for images and again for audio files. Is the answer two seperate files sections?
Also, when i upload MP3 files, its getting the wrong mime type of “application/octet-stream” which should be “audio/mp3” or “audio/mpeg”.
Not sure if thats a browser thing or a kirby thing.
There’s a problem with your code:
$this
doesn’t refer to the file, you have to use the $file
variable you pass as argument in your function.
Also, don’t echo anything from your hook, but you can throw an exception to inform the user if something didn’t work.
You can only have one template per section because you don’t have a dialog where you could choose your template otherwise.