Okay, I’ve followed the cookbook instructions as best as I can a few times and I don’t think this article explains completely how to go about this task:
I think being more specific with describing the steps to go about this would be more helpful.
Is there a better walkthrough about adding Users as Authors and linking to possible Author pages, for example?
Thanks in advance…
Well, I think I got pretty far along a few times, but then I started tinkering to add Author pages and that fell flat.
In this case, perhaps creating Authors and Author pages from the Users is done differently. I assumed that I could create and link to Author pages and list all of their Articles on those pages. I’m still struggling with that.
But perhaps I need full walkthroughs instead of general recipes in a cookbook.
You can link to either Kirby users using the users field. Or you can link to one or multiple authors that are subpages of an authors (or whatever you want to call it) page. In the second case, you cannot use a users field but have to use a multiselect field.
The cookbook recipe you mentioned above refers to linking to authors that are created as Kirby users, not as subpages in the content folder.
I did see some action when I used the multiselect in testing. That’s an interesting caveat. I’ll try that.
Re: Cookbook recipe: Ah, that’s perhaps where I’m misguided. Is it possible to do both? …have Author pages that reference Users on the site? Or do panel users have to be separate from Author pages that reference Content data about themselves? That’s probable. Okay.
I suppose to allow users to log in and create a blog post for themselves… or something similar.
But yeah, I understand that’s crossing the streams perhaps.
I just don’t see the purpose. Maybe you can explain it a bit better.
Why not create all your authors as Kirby users? What would be your use case for having authors that are not Kirby users? If you want to include users with no Panel access that create content from the frontend, they could still be Kirby users with a different role.
Of course, you could also mix Kirby users and authors from subpages of an authors page in a multiselect field if you wanted to.
Ohhhhh. Apologies.
That is in fact what I’d prefer. To have Users also be Authors on the site (instead of maintaining two places where data lives). Apologies if I hadn’t explained myself correctly.
However I can’t seem to make it happen. Should there be an Page/Authors.yml that references a Users/author.yml?
In essence, when I read the Cookbook entry about adding Authors to a site, THIS is exactly what I thought it meant. But it doesn’t do all of that. If it does, it doesn’t communicate the steps properly i think, hence my post here about it.
Yeah, this is great. Thanks, @texnixe!
My main goal is multiple authors, what permissions they have is not important.
So, if I wanted individual Author Pages to show the Author’s bio and all of the Articles they’ve written, how would this be constructed?
Since Kirby users can have fields in the same way that subpages can, you would create one or more blueprints for each user role.
You would then use a users field to link blog posts to your authors.
If you want to have user pages that list their articles, the best way to go about that would be to create an authors page (but without subpages for authors) and then use a route to link to the individual users and list their articles.
Your route would look something like this and return the authors page with the user as variable you can then filter by in your authors.php controller:
I’m not sure how to setup routes at this point, but I have looked into it. I’m not an PHP dev, but tinkering got me this far. I’ll likely go with making people as another section of the site instead of via Users. Thanks for your help on this.
This is correct.
I’d looked at making virtual children, too, but that defeats the purpose of having a filebased data collection for me. Also, my brain won’t fully wrap around it, so there’s that!
Check out the AuthorsPage model in /site/models/authors.php
Note that the code is lacking some checks like if a page exists etc., so please regard this as quick and dirty.
This allows you to define authors with permissions and nevertheless have author pages without using routes. The fields (actually only the email field in this case) for the authors are made readonly to not mess with the user content.
Also, you would have to fine-tune the blueprint options for the virtual children etc.
Thank you so much, Sonja. This is above and beyond the support I’d expect for the cost of the app.
Very interesting.
So, I’m looking at the /site/models/authors.php which is interesting. So this is the glue that combines the Users as Authors to the Authors page, correct? This’ll work great.
Excactly. If you look at the authors.php template, you see that you can now link to the individual users as if they were real subpages. And if you click on a link in the authors page, you will automatically go to a single user page.
There are several parts to it. The model is main element, then there is the part that filters the articles by author in /site/templates/author.php.
As regards the fine-tuning:
The page options for the users are pretty useless, you don’t want to duplicate users, change their URL etc. so you would actually have the following settings in /site/blueprints/pages/author.yml: