Multiple Authors - General questions

Hey there.
I browsed through a lot of different theads, plugins & solutions for various problems surrounding the topic ‘Integrating multiple authors with Kirby’. I want to set up a system and could use some pointers in the right direction, maybe this could be a general thread discussing this (future core?) feature.

Adding / accessing multiple authors (per page)

1. Authors as subpages OR creating/using users

While adding authors as subpages (cookbook approach) might work if they don’t need access to the panel (eg they are submitting pages through other channels, for review, etc), I find it a simpler solution to use Kirby’s built-in user management system (which can even be improved, see userManager). Also it seems harder to filter through subpages in the next step …

2. Method of selecting users from panel

Without using a plugin

  • Checkboxes using JSON query API (thx to @texnixe)
  • Structure field that only contains one user panel field like this:

Using a plugin

users field (for fixed version see this thread), also a checkbox solution offered by controlledlist plugin, even tags are mentioned (like the guys from macotuts) but personally I’d prefer something like @distantnative’s MultiList plugin (as mentioned here):

Another similar solution could be this: extending the existing user panel field to allow for multiselect. But how to fetch all that data?

3. Fetching data from selected user(s)

First, a viable solution needs to work with one or many authors.Then, how to connect the given usernames in a template with their respective user information? PHP-wise, splitting multiple authors and calling their individual data is beyond my capabilities. BUT I really love Kirby and want to use it for clients, because (at least on their end) it’s pretty darn simple and fun to work with, seeing stuff just fall into place like it should be.

Following the solution from 2. using the MultiSelect plugin, we could do something like:

<?php foreach($page->authors()->split() as $author) : ?>
  <p class="authors">
    <?php echo $site->user($author)->firstname() ?>
  </p>
<?php endforeach ?>

Any pointers, recommendations are valuable, any input or enhancement is welcome.
Thanks for your contributions to this project, keep up the good work,

daybugging.

1 Like

Whether or not you use checkboxes or a multi select field, you always end up with a comma separated list of options which you can fetch using the code snippet you posted above.

Another option to add multiple users (to an article) without any plugins would of course be the structure field with a single user field in it.

Which would make organizing users / accessing user information on a (real) global scale (backend-wise) impossible.

I’m afraid I don’t quite understand what you mean?

I meant this as an option for selecting users, not for organizing users.

Edit: If I needed users with Panel access, I would stick with the inbuilt user management.

I meant organizing author information on a per-page basis, using structure fields, I’d have to go each article, changing information about this author, instead of changing it globally (per user-management). So if something changes, author bio for example, I’d have to change this bit in every article he wrote.

// Edit:
So for a Kirby-wide solution to this, structure fields are not a real option :slight_smile:

No.

As I tried to clarify above, I meant to use a structure field as a means of adding multiple users to a page:

field:
  authors:
    label: Add an author
    type: structure
    fields:
      author:
       label: Author
       type: user

As an alternative to a multi select, not as an option to add information about the user. I just added this option as an alternative to using a multi-select plugin (or any plugin at all).

The other option without plugin would be checkboxes with the JSON query API.

Ahh, so I mixed stuff here, I’m sorry. Got it now :smiley:

I don’t think tags are a good option, actually, because that field let’s users add anything, not just existing users.

As this thing is growing and could be a good starting point for related issues in the future, I will add a “discouraged” badge or something to this option - I included it because people are actually using it, see how desperate they are? :wink:

Well, now I dont know how to count the authors, only get errors … pls help!

If you tell us how you stored your authors, I’d love to help.

Well, like described above :slight_smile: The authors are inserted via MultiSelect plugin, which extends CheckboxesField

Ok, then you have a comma separated list.

To get the authors, fetch them in an array using the split() methods. Then you can use the php count() function to count the elements in the array.

$authors = $page->authors()->split();
$noOfAuthors = count($authors);

That’s where I was mistaken using Kirby’s ->count(), thanks again!

Yes, the Kirby count() method is a method of the Collection class, so it only works with collection objects, not with arrays.