on a blog page blueprint there is a files section called “inbox” using the inbox template which accepts certain file types
once a file has been uploaded a validation step hooks in using janitor jobs
certain files which are in the right format shall be “forwarded” to the media pool which means i’d like to change the files’ template to medipool
these files shall be listed in a second files section with mediapool template filter
other files will be converted into a more common format and then being forwarded to the mediapool
I am wondering how i could solve:
a) changing the template of a given file afterwards (through file.create:after hook)
b) prevent a files section from uploading files to it as all files shall be uploaded only to the “inbox” where the “validation” magic is triggered
no, save() is implictly called by ModelWithContent::L779 … i drilled it down to
File::L202 where the template explicitly got overridden by $this->template and there is no setter or changeTemplate method to change the given template afterwards. Which leads me back to my original question ;-).
Any idea on how to change a files’ template afterwards? Probably i have to somehow create a new file with the intended template and deepCopy the original content into this new file with the new template?
hmm … i saw code branches in case of multiglange versus single language installation. Could this be difference? I am on kirby 3.5.7.1 . I will have a look through the code and search for concurrent triggers in other plugins. Also my trigger is located within a plugin and not config.php.
But good to know, that a trigger should work in general Thanks!
In a multilang installation, you have to pass the language code of the language you want to update as second argument. If you don’t, the default language is used.
In my setup there are to file.create:after hooks configured. One in config.php which updates the file and adds creator (user) and createdAt (date). And another hook in a dataformat conversion plugin which converts an m4a into an mp3 file.
After removing the hook in config.php the template is updated properly. So it seems to config.php hook which is called after the plugin hook overrrides the changes again.
Is there a way to break to hook-chain programmatically? Is there a rule that plugin-hooks are called before config.php hooks?