I followed this guide (Virtual pages from image gallery | Kirby CMS) to create a gallery (did not add it via a plugin, only the way described first) and now I have the problem that for the sitemap (created following this guide: Sitemap | Kirby CMS) the virtual pages do not have a lastmod value.
Is it possible to create a lastmod value for virtual pages or is there another way to workaround a possible limitation?
You would have to overwrite the modified()
method in the GalleryImagePage model. Maybe use file modification date.
Even tho this makes sense, I have no idea how to do that. But I was able to just add following code to the sitemap.php and that seemed to work:
<?php if ($image = $p->image()) : ?>
<lastmod><?= $image->modified('c', 'date') ?></lastmod>
<?php else : ?>
<lastmod><?= $p->modified('c', 'date') ?></lastmod>
<?php endif ?>
This will give you the image modification date for each and every page that has an image. Doesn’t really make sense, does it?
That is correct, but in that case all other images are added via a block element and it seems to work. Working means it looks correct. But again as I have no idea how to adjust the code without another hint (or 5) it will have to suffice for now.
<?php if ($image = $p->template() == 'gallery-image') : ?>
<lastmod><?= $p->image()->modified('c', 'date') ?></lastmod>
<?php else : ?>
<lastmod><?= $p->modified('c', 'date') ?></lastmod>
<?php endif ?>
I guess a cleaner option could be to check if the template if ‘gallery-image’ and then use this in the sitemap.php