Good evening,
I have a very simple thing I want to accomplish but I am stuck. The task: in my site/config directory, I have a file called “something” which contains a string representing data in JSON format.
I now want to read the file and (assuming I would automatically get an object) return one specific value of the object called “otherthing”.
But I don’t get to this point - I fail on even reading the file. The new File() docs is really not helpful. It says I should use $props[‘url’] and when trying to set the URL (wrongly?) the debugger complains about invalid arguments, stating “The filename and parent are required”. I tried to add a “root” value to the array but no luck either.
$textFile = new File(['url' => $kirby->url('site/config/something')], );
$file = $textFile->read();
return $file->otherthing;
What am I a doing wrong here?
Thanks for your help,
Andreas