QRC in admin
4 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: January 25, 2016 (RSS)
By Toledoh - January 20, 2016
Hey guys.
How would I go about creating a QR Code in the admin. ie. I want to be able to create a record in a multi record section, and have a QR Code created for that record and displayed in the admin for the administrator to print out and use.
It can be random or based on the num of the record etc - but has to be unique.
Tim (toledoh.com.au)
Hey Tim,
The simplest way to implement this feature is to create a separator and add custom HTML and PHP that displays a QR Code. The QR code gets the num of the record from the URL and uses that variable to create a unique ID. This QR code will appear after the first time they save the record.
Here is the code I added to the separator:
<?php
if(@$_REQUEST['num']){
echo qrCode(array(
'type' => 'text',
'text' => 'Hello world! ' . @$_REQUEST['num'],
));
}
?>
I've attached a screenshot that shows how I implemented this code into the separator.
The user would be able to print this by right clicking on the QR code and clicking 'open in new tab'. From here they could print the code without the other page content.
Let me know if you have any questions.
Cheers,
Greg
PHP Programmer - interactivetools.com
By Toledoh - January 22, 2016
Thanks Greg.
I've implemented the following:
<tr><td>
<?php
if(@$_REQUEST['num']){
echo qrCode(array(
'type' => 'text',
'text' => @$_REQUEST['examplecode'],
));
}
?>
</td></tr>
And this in the front-end page
<div class="col-xs-3 qrc">
<?php
echo qrCode(array(
'type' => 'text',
'text' => $record['items.examplecode']
));
?>
</div>
However, they create different QRC's as attached. The one from the front-end can be read, but the one from the admin can't. Any ideas?
Tim (toledoh.com.au)
Hi Tim,
I thought I'd post the solution we used to resolve the issue to this forum thread:
<?php
if(@$_REQUEST['num']){
$record = mysql_get('blog', $_REQUEST['num']);
echo qrCode(array(
'type' => 'text',
'text' => 'Hello world! ' . @$record ['title'],
));
}
?>
So the code above was added to the separator HTML field. It will retrieve the current record if it exists, and allow you to access any variables from the record. You'll need to update the variable blog with the section you're currently editing.
Just a note, this will load the data from the previous save of the record. So in this example if you made any changes to the title, they won't appear in the QR code until you reload the record.
Cheers,
Greg
PHP Programmer - interactivetools.com