QR Code Generator Configuration Options

3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 17, 2013   (RSS)

By Mikey - March 31, 2013

I'm sure this question has been asked, but I can't seem to find it, nor can I find any details on Google about how I can alter the configuration of how the QR Code works.

So my question is... can I use the code below (without an email address) and still produce a QR Code so that all the other details produce a QR Code? As it works now, there must be an email address to produce a QR code, but I'd like to create an option for just address and contact details - even if no email address is present.

<?php echo qrCode(array( 'type' => 'contact', 'size'   => '160', 'firstName' => $diningRecord['firstname'], 'lastName' => $diningRecord['lastname'], 'address' => $diningRecord['address'], 'phone' => $diningRecord['phone'] )); ?>

If it is possible, can someone share some code, or light on how to make this work?

Thanks Zick

By gregThomas - April 1, 2013

Hi Zick,

I've had a look at the plugin, and I think the easiest solution is to modify the plugin so that it's possible to leave the e-mail field blank. You'll need to modify the code of the QRCodeGenerator.php plugin file on line 120 so that it looks like this:

/*if (array_key_exists('email', $options)) {
  if (!isValidEmail($options['email'])) { $errors .= "Invalid value for option 'email'!\n"; }
}*/

This stops the plugin validating the e-mail address, allowing you to leave the e-mail field blank if required:

<?php echo qrCode(array( 
  'type'      => 'contact',
  'size'      => '160',
  'firstName' => $diningRecord['firstname'],
  'lastName'  => $diningRecord['lastname'],
  'address'   => $diningRecord['address'],
  'phone'     => $diningRecord['phone'],
  'email'     => '',
 )); ?>

This does mean that if you do add anything to the e-mail address field, you'll have to make sure its validated before adding it to the qrCode function.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com