i use the blueprint from the portfolio documentation -> https://getkirby.com/docs/reference/panel/samples/portfolio#projects-overview
and i want to access the “cover” field which is in the project.yml but it’s not working.
I just want to set a coverimage in the panel in my project page and that should show up on my main page. But when i use
Is it possible that cover returns a collection of files? If so, please try $project->cover()->first()->toFile(), or set multiple: false in the blueprint (more info: https://getkirby.com/docs/reference/panel/fields/files).
When extending blueprints, pay close attention to the type (field / section) you are extending.
Your cover files field is actually a cover files section, if you check your txt file you will see that there is no content stored associated with a cover key.
When you upload an image in this cover section, Kirby gives the Cover | blueprints/files/cover.yml template to your uploaded image (this is what the template: cover option is for).
Therefore to retrieve it later in your template, you’ll have to call:
Thank you very much for your response!
I thought in a similar way but i am a little confused, because there is no “cover.yml” blueprint in the section you wrote. I use the starterkit-master And when i delete “template: cover” nothing elses changes in the panel and the cover image is also shown on the main page Very strange. At least it works now! Thanks!
The cover.yml blueprint doesn’t have to exist to give the cover template to an image. Basically you’re attributing a template name to the uploaded image (check in your content folder, Kirby creates a txt file alongside your image, with the template key / value pair). If the corresponding yml file doesn’t exist in the blueprint folder it will fallback to the default file blueprint. If now you add a cover.yml in your files blueprint folder, your file will switch to this one.
template: cover, is both a filter and a way to add a dedicated blueprint on upload. Removing this options means removing any filter, so your section will now display all files and won’t associate any template to newly created ones. If you set this option to template: anotherblueprint, then your file previously uploaded with the cover template won’t show up anymore.
If you have uploaded an image with the template: cover option, and then removed the option from the section, the attributes of your already-uploaded image won’t be removed, it’ll still have the cover template associated to it. Therefore it’s normal that it’ll still show on your main page. Hope it’s clear.