I know this is not the first time for this topic, but I have tried as far as I know every solution that I was able to find. Including different Kirby-Forum entrys, XAMPP config changes, Loading the default starterkit and its content (almost the same problem there) …
I’m using:
XAMPP Control Panel v3.3.0
Kirby 4.5.0 (info from panel)
PHP 8.2.12 (info from panel)
Apache/2.4.58 (Win64) OpenSSL/3.1.3 (info from panel)
starterkit-main
Basically I’m using the photography template to host my projects.
As far as I can remeber I only changed the following from the starterkit:
changed the template of the pages-template to an abrevation of the about-template
changed the template that is used by photography tho this edited default template
added the cover field to the used template
This is how the Site looks right now (on localhost):
The following cover-php-version will show the cover images, but if there is no cover image selected it will show the “unexpected error” page. Also a friend of mine said thats not a good option.
Sorry, that doesn’t really help. We are talking about your frontend code and you are using a variable called $album, which refers to a page type. What is the name of the content file of this $album page? default.txt? album.txt? something else?
Not really but thats because I’m kinda confused.
On one side, the current code is as you suggested on the other side I’m unsure what to rename.
But maybe thats because its my third day sitting infront of this exact problem with alot of back and forth and my mind got a bit stuck over it (Can’t see the forest for the trees)
Let’s go one step back. If you have a files field like this cover field and you want to render the file whose value is stored in this field, you usually use this code (assuming you are on the page itself:
Now the Starterkit has a page model for the album pages (which used album.txt as template name) with a function that has the same name as the cover field, see AlbumPage class above. This method overwrites calling the cover field (method takes precedence over field name).
So, now you have renamed album.txt to default.txt, therefore the cover() method originally called in the home.php template in the Starterkit won’t work anymore. And that’s the reason you now either
have to call toFile() on the cover field
or also rename the site/models/album.php model to default.php and change the class name inside that file from AlbumPage to DefaultPage
After trying alot of renaming which didn’t help I did the following approach:
I looked into my Browser Console and into the Error Codes that appeared there. After some research and a look into the XAMPP Apache error logs I stumbled upon the following error there:
Exception: Required extension GD is not loaded. in C:\\xampp\\htdocs\\kirb [...]
Which I fixed by adding extension=gd to the bottom of the php.ini File in the Apache Control Panel. Which also fixed the Cover Image Problem for the default content in the starterkit-main