Plugin: QR Code – Field and Page-Method

Kirby CMS Panel Field and Page-Method rendering a QR Code.



Add a kirby panel field to your blueprint to show a qrcode of the kirby $page->url() within the panel. This plugin uses a global field definition to cut some corners.
Default paramters of QR code lib will be used to render the image or the parameters set in your config.php.

#fieldname: fieldtype
qrcode: qrcode

Page Method

The plugin also adds a $page->qrcode() function which returns an image as Media object to use in templates etc.

You can use the default values, override them or set your own parameters on-the-fly using an associative array. Missing parameters will fallback to defaults of lib.

$qrcodeDefault = $page->qrcode(); // Kirby Toolkit Media Object

$allCustomParameters = [
	'Text' => $page->url(), // plugin default
    'Size' => 300,
    'Padding' => 10,
    'ErrorCorrection' => 'high',
    'ForegroundColor' => ['r' => 0, 'g' => 0, 'b' => 255, 'a' => 0],
    'BackgroundColor' => ['r' => 255, 'g' => 255, 'b' => 255, 'a' =>0],
	'Label' => 'You take the blue pill',
    'LabelFontSize' => 16,
    'ImageType' => Endroid\QrCode\QrCode::IMAGE_TYPE_PNG,  // lib default
    'Filename' => $page->slug().'-qrcode', // plugin default

// override defaults. this can be done in config.php as well.
c::set('plugin.qrcode', $allCustomParameters);
$qrcodeCustom = $page->qrcode(); // using new defaults now

// or use them on-the-fly
$qrcodeCustom = $page->qrcode([
    'Label' => 'You take the red pill',
    'ForegroundColor' => ['r' => 255, 'g' => 0, 'b' => 0, 'a' => 0],
    'ImageType' => Endroid\QrCode\QrCode::IMAGE_TYPE_JPEG,

// then use media object to get brick and echo the image
echo $qrcodeCustom->html();

k3 version:

1 Like

Why would you use a QR code on a website? Is a simple link not better?

If the visitor has a mobile, he/she can make a photo of the QR from any other screen and don’t needs to type the link on his mobile.

What do you mean with “visitor”?

A visitor is a visitor (in German: “Besucher”) e.g. in a company, who wants to have the homepage link of the company at his/her mobile.
The screen with the QR is owned by the company and e.g. in front of a wall in the public parts of that building.
Or on a German website:

You can actually stuff quite a bit of stuff into a QR code, not just a page link. Depends what you want to share with it. But, generally your right… QR codes are best used in printed matter.

Thx. Such a weird use case. Isn’t a static page (or printed poster?) not better for this?

Personally I wouldn’t want to change the links on my sites to cater such “kiosk visitors” as they litter the rest of the page for everyone else.

i use with a non-public booking plugin i created. pdf invoices based on html layout (using mpdf) including the qr-code image are send to customers per email (and online version). the qrcode can be a link with token to make it more secure.
at the event the ticket can quickly be verified by the staff with just a regular mobile phone - scanning the qrcode from customers mobile screen.

1 Like