array_keys($page->parents()->toArray())
Ok, some small progress, I changed the way i using the full path, and now the tiles are not being moved to the media (hurrah!)
I just need to fix the plugin, and stop the xml doing it too.
Edit… post clash… plugin fix in progress
Looks like you cant do $page
here (panel complains about undefined variable)…this is what i tried:
<?php
Kirby::plugin('hashandsalt/kirby-skip', [
'components' => [
'file::url' => function (Kirby $kirby, $file) {
$parents = array_keys($page->parents()->toArray());
if (in_array('tiles', $parents)) {
return $kirby->url() . '/content/' . $file->parent()->diruri() . '/' . $file->filename();
}
}
]
]);
Well, you have to get the page via the file, as said above.
Well i tried that too…
$parents = array_keys($file->parent()->parents()->toArray());
Panel says…
Return value of Kirby\Cms\File::url() must be of the type string, null returned
You probably have to return something in case the condition is not true, i.e. the normal URL for files.
yes, i see. the page im looking at in the panel is the page that has the tiles folder as a subfolder, so ‘tiles’ isnt part of the url yet.
Whats the normal way that kirby puts the path together for a file? I tried this but i upsets every page…
<?php
Kirby::plugin('hashandsalt/kirby-skip', [
'components' => [
'file::url' => function (Kirby $kirby, $file) {
$parents = array_keys($file->parent()->parents()->toArray());
if (in_array('tiles', $parents)) {
return $kirby->url() . '/content/' . $file->parent()->diruri() . '/' . $file->filename();
} else {
return $file->url();
}
}
]
]);
'file::url' => function (App $kirby, File $file): string {
return $file->mediaUrl();
},