Using site.yml blueprint fields as page

Hello, I have a few settings that need to use site wide, image upload and some some custom css controls on every page.

I’ve tried using <?= $page->cover() ?> but no luck, site->cover works but it’s not available on the rast of the pages. I’ve tried this in a new way <?= $page->theme()->or($site->theme()) ?> still I feel it’s kinda wrong.

my final problem is uploading a cover image using this blueprint:

            lable: Cover
            type: files
            query: images

When I try to export using $page->cover()->url I get only the file name not the whole url to the file

A files field only stores the id of a file, you have to convert the field value to a file object first to be able to call any member methods like url() etc. on the object:

This is documented in the files field docs: Files | Kirby CMS

For site wide images, store the file in the site object, then use $site instead of $page in the same way as in the linked docs.

Thanks for the reply, I managed to get it working tho not in a traditional way. I had to make two header snippets similar to this one, one for site and one for page:

background="<?= $site->theme()?>" 
position="<?= $site->position() ?>"
<?php if ($site->color()->isEmpty()): ?>
<?php else: ?>
style="background-color: <?= $site->color()  ?>;"
<?php endif ?>>
<?php $img = $site->cover()->toFile() ?>
<?php if ($site->cover()->isEmpty()): ?>
<?php else: ?>
	<img class="bg" src="<?= $img->url()  ?>" alt="" />
<?php endif ?>

What’s the point of these if-else statements when the if part doesn’t do anything?

IMHO it should read:

<?php if($img = $site->cover()->toFile()): ?>
	<img class="bg" src="<?= $img->url()  ?>" alt="" />
<?php endif ?>

Might be true, tho I have no experience with php what so ever. What was put up there is a compilation of things i’ve found on the internet, trying to see if Kirby and I fit.

I only know HTML and CSS at the moment, as I am into design and this role demands it. Maybe it’s time to learn php. I would pick something else but I’m scared of Javascript :sweat_smile:

Still, thanks for the help