I followed the cookbook recipe for adding an authors page but it is always empty and I don’t know why. It seems to be related with the first variable but the author field exists and is set.
authors.php template:
<?php snippet('header') ?>
<?php
// fetch all used authors emails from all articles
$authorlist = $site->pages()->pluck('author', '-', true);
foreach($authorlist as $author):
echo $author; // no visible output
endforeach;
// get a list of all authors filtered by the ones with articles
$authors = $kirby->users()->filterBy('id', 'in', $authorlist);
?>
<h1>Authors</h1>
<?php foreach($authors as $author): ?>
<article class="author">
<h1><?= $author->name() ?></h1>
<?php if($avatar = $author->avatar()): ?>
<figure>
<img src="<?= $avatar->url() ?>">
</figure>
<?php endif ?>
<?php if ($blog = page('blog')): ?>
<ul class="articles">
<?php
// filter all articles per author
$articles = $blog->children()->listed()->filter(function($child) use($author){
return in_array($author->email(), $child->author()->yaml());
});
foreach($articles as $article): ?>
<li><a href="<?= $article->url() ?>"><?= $article->title() ?></a></li>
<?php endforeach ?>
</ul>
<?php endif ?>
</article>
<?php endforeach ?>
<?php snippet('footer') ?>
Example content of one blog article:
Title: Example title
----
Author:
- kOBKf1Qa
----
Intro:
----
...