Random Text Strings inserted funtime

So, I previously had a string of text randomly constructed from strings on pages in a previous project. I’ve assembled a bit of nonsense in the K3 Panel to show how something like this might work, on the off chance it helps anyone ;).
Also, I should say that I’m taking a bit of knowledge from what @texnixe shared in a post here:
https://forum.getkirby.com/t/static-variable-within-a-snippet/14871/9

Here goes:

  1. Add some Fields to your Site (or any other blueprint). Set them up as Tags. Add Labels if needed:


    Then insert your strings as show above.

  2. Create your randomizing arguments on the template like so to get a By, When, and How:

<!-- random strings assemble! -->
<?php $ranwhen = $site->ranwhen()->split(','); shuffle($ranwhen); $when = $ranwhen[0]; ?>
<?php $ranby = $site->ranby()->split(','); shuffle($ranby); $by = $ranby[0]; ?>
<?php $ranhow = $site->ranhow()->split(','); shuffle($ranhow); $how = $ranhow[0]; ?>
  1. Insert your strings where you’ll need them:
<p><?= $by ?>
<?php foreach ($page->person()->toPages() as $person): ?>
	<a href="<?= $person->url() ?>"><?= $person->title() ?></a>
<?php endforeach ?>
<?= $when ?> <time><?= $page->date()->toDate('F jS, Y') ?></time> <?= $how ?></p>
  1. Then load up your page and get the following randomness:
    "Recovered at the scene by Luke Dorny about February 25th, 2011 after it was all said and done."
    or
    "Scribbled by your hero Author Name on or about February 25th, 2011 despite their best efforts to fail."

(In fact, you may be able to make this a Snippet, too.)

There you go! Make a MadLibs, or whatever you’d like with it. You could access these sitewide, as I’ve shown here, but surely there’s a funner way to do this. Know a better way? Store the strings on a per Article template basis instead? Who knows!? Enjoy!