I need to include data from a yaml-file to each page. The yaml-files are located in each page folder and they have all the same name (data.yaml).
So I wrote a plugin, reading the file
$filename = $this->grav[‘page’]->path().’/’.'data.yaml’
assign the filecontent to twig-variables, which I can use in the templates.
This works fine for single pages. But as soon as I use collections, all the children included in a listing page does not show the content of their own data-files located in their childrens folders. They all show the same data from the data-file of the parent folder.
I think I can understand this behavior, obviously the plugin does not restart recursively for processing each of the childrens pages.
To achieve the intended behavior, probably I need to change the path of my $filename somehow, but I have no idea how.
Thanks for help.