Normal beahvour of a cover should be:
Set a cover
Set no cover
and maybe cover = Setcover or first picture (like in the demo)
but i dont want to have a covcer, i also dont want to upload a 1x1-picture to fake this function.
How can i tell Kirby to do:
Show cover if set cover
Show nothing, if cover is not set.
In the Starterkit, there is a cover method in the
note.php models (/site/models), which falls back to
$this->image() when no image is selected. Remove this fallback so that the
cover methods then looks like this:
public function cover()
Or remove this method and adapt the template code.
The problem goes further, because the cover-picture is also used for the preview.
When i remove the fallback, i dont have any pictures in the preview.
So i should have two functions, one to show in the preview with fallback, and one to show in the detailed page without the fallback.
Next question is: I have copied all my news from the Starterkit to my clean new site. They afe visible on the page, but not in the panel. I try to compare Starkerkit and newSite, but … i have not founf the key yet.
Not necessarily, if you don’t specify an image in the section, Kirby will automatically choose an image from the file system. Or you use query language to fetch an image.
Note that the cover method in the model is just an example to showcase models and use the fallback functionality. Instead of using this method, you can call the code inside that method directly in your template.
Depends on where you want to show the news. If on the Dashboard (start page of the panel), you have to specify a pages section with the new page as parent. See section documentation: Pages section | Kirby CMS
Quick and dirty solution is to add cover2() in models>note.php with fallback and cover() without. Now i have a picture in the preview as long there is one and no cover on detail-page.