Hey there
I’m making a website that has articles written by different people. Basically an online magazine. In my article blueprint I can select an author, which is actually a Kirby-user.
Now I want a page, that lists all other articles written by the same user.
It seems that the other questions in this forum use pages and subpages as user. But I already created all the users and linked them with their written articles inside the panel. Can someone give me a hint if I should just make a author.php besides the authors.php? The authors.php has no subpages, so I don’t know how to fetch each user. Another idea is to store the name inside the URL and hide all other profiles iin the authors.php, but that seems too odd to me.
Create a parent page authorsand a route with a pattern authors/(:any). In your route action, return the authors page and pass the author as an argument.
Create an authors parent page and create the authors as virtual children of this page. Then on each author page you can display all articles that belong to that author. I think I’ve posted an example of this recently, trying to find it
Sorry, but I don’t get either of them. Can you may help me with the first? I have an authors.php inside templates. Like it is in the cookbook.
The second one I tried to implement. They are still users without subpages, so I cant just use <?php foreach ($page->children() as $user): ?> And when I go to the Panel and click authors, it’s empty. I copied the models/authors.php, maybe I have to modify it somewhere, but it’s just to much files without documentation.
The important part here is the model, in the example, I filter by role= author, if you don’t have an author role, you have to remove the filter. The example was intended for the use case in the other thread.
To make the example work you need:
a content folder authors with an authors.txt inside
the template /site/templates/authors.php for the authors overview
the model /site/models/authors.php that defines your users as children of the authors page
a site/templates/author.php template for the individual authors
In the example, the field in the articles where the user is stored is called authors instead of author, so you would have to adapt that in the author.php template. Also, if your blog overview page is called differently, in the example it is called blog-
Hey – one thing:
It’s working, but how do I add an an bio to the author?
I’ve added an textarea field to author.yml (blueprint->pages), but whenever I enter something, it suddenly disappears. Like, I press a key, see the letter one moment, then it’s gone. It seems like another kind of problem, but maybe it’s associated to this.
I think you should really edit your users in the users section, not as children of the authors page in the Panel, so create a /site/blueprints/users/author.yml