Kirby CMS Tag to generate various random values.
This plugin is free but if you use it in a commercial project please consider to make a donation 🍻.
- Kirby 2.3+
- Since version 1.3.0 this Plugin does not required php7 anymore
kirby plugin:install bnomei/kirby-random
$ git submodule add https://github.com/bnomei/kirby-random.git site/plugins/kirby-random
- Download the contents of this repository as ZIP-file.
- Rename the extracted folder to
kirby-random
and copy it into thesite/plugins/
directory in your Kirby project.
Random string using Kirby Toolkit str::random()
forwarding the type if any.
(random: 5) or (random: 5 type:alpha)
Random positiv non-zero number with max value inclusive using PHP random_int()
(or rand()
in php5).
(random: number length: 128)
Any one value of a comma seperated list.
(random: apple, banana, coconut)
Any random pool of values picked from a comma seperated list with optional length.
(random: red, green, blue, black, white, yellow type: pool)
or
(random: red, green, blue, black, white, yellow type: pool length: 3)
A number between a min and max value inclusive using PHP random_int()
(or rand()
in php5).
(random: 41, 53 type: between)
Lorem Ipsum
text using a generator.
(random: lorem length: 5) or (random: lorem type: words length: 4)
(random: lorem type: sentences length: 3)
(random: lorem type: paragraphs length: 2)
(random: lorem type: chars length: 140)
The plugin also adds a $site->random()
function to use in templates etc.
// STRING
echo $site->random(23);
// NUMBER
echo $site->random([41, 53], 'between');
// POOL
// from a comma seperated string
echo $site->random('red, green, blue, black, white, yellow', 'pool', 3);
// or a php array
echo $site->random($myArray, 'pool', 3);
// LOREM
echo $site->random('lorem', 'paragraphs', 3);
This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.
It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.