Adding a FAX field, or other simple field, to QR Code Generator Plugin

By Codee - January 30, 2012

I'm finally utilizing the QR Code Plugin and I have 3 clients who are really hot to trot for using it. My first sample page worked very well but I have a question. I'm using the "contact" sample...I tried to add a field for a FAX number on the QRCodeGenerator.php page. Even though I mimicked the "phone" entries on that page, the page broke. Is there an easy way to add fields that are in the database or is it a major operation to do that with this plugin?

Re: [equinox69] Adding a FAX field, or other simple field, to QR Code Generator Plugin

By (Deleted User) - January 30, 2012

Hi Equinox69,

The QR generator for contact details uses the MECARD standard which only defines one phone number. It can have more than one phone number added but it doesn't store the difference between numbers (ie work and fax would both come up as 'tel') and so the software reading the QR code would (hopefully!) ask to define which number goes where.

If you want to add an extra field then you can edit the plugin code directly to capture and then output the extra field (just rename the plugin 'QRCodeGeneratorCustom' so that it doesn't get overwritten if you upgrade).

Hope this helps,

Tom

Re: [Tom P] Adding a FAX field, or other simple field, to QR Code Generator Plugin

By Codee - January 30, 2012

Hi Tom, thanks for replying. I opened QRCodeGenerator.php and searched through the fields for the contact info and found 'phone' and 'address', etc. Everywhere those fields were on the plugin I appropriately added a new field, called "FAX", then double and triple-checked to ensure commas, etc. were all done correctly. Uploaded the page and it crashed the plugin. Quickly removed the fields I added and it was back to normal. I'm reading from you that a field can be added, BUT that the contact details is following a standard. If I'm adding a field that's not part of that standard, won't it crash on any field I add?

Re: [equinox69] Adding a FAX field, or other simple field, to QR Code Generator Plugin

By (Deleted User) - January 30, 2012

Hi equinox69,

My guess is that you have this line (49 in the r1.00):

elseif ($type == 'contact') { $data = 'MECARD:N:' . $options['lastName'] . "," . $options['firstName'] . ";ADR:" . $options['address'] . ";TEL:" . $options['phone'] . ";FAX:" . $options['fax'] . ";EMAIL:" . $options['email'] . ";;"; }

With the variable "FAX:" set to the fax number.

I forgot to mention that when calling the MECARD api, all telephone numbers are listed as TEL, so this version:

elseif ($type == 'contact') { $data = 'MECARD:N:' . $options['lastName'] . "," . $options['firstName'] . ";ADR:" . $options['address'] . ";TEL:" . $options['phone'] . ";TEL:" . $options['fax'] . ";EMAIL:" . $options['email'] . ";;"; }

should work

You'll also need to update the error checking on line 89:

'contact' => array('type', 'size', 'margin', 'mode', 'lastName', 'firstName', 'address', 'phone','fax', 'email'),

Hope this helps,

Tom