You can access the parent of a file (i.e. the page the file belongs to) with $file->page(). This gives you the page object and with it you have access to all fields of that page.
how do i need to access my text field content from a field called “voiceid” i’ve tested this
$file->page()->content()->voiceid()->text()->value()
but it didn’t worked.
i’ve tried with all of the recommended solutions to get the field. but with the code below and all other way to get the filed i always get the error “Call to a member function content() on null”
'hooks' => [
'file.create:after' => function ($file) {
voiceImage($file,$file->page()->content()->get('voiceid')->value());
},
my Blueprint looks like this
fields:
voiceid:
label: voiceid
type: text
do you got any idea why this isn’t working.
The hook is placed in a plugin and works perfect without getting the voiceid.
i’ve found the reason why it doesn’t work. i’ve uploaded the files to another folder so there was no folder with pagename and therefore no page object in the File (i’m using virtual pages from DB)).
After removing the uploads Parent everything worked as expected and the Page Object was available.
uploads:
#parent: site
template: voiceimage
Btw. ofcause it is documented in the docs, but not so nicely and detailed like you told it to me . Thanks again for the great support.