Using QR Codes in phpMyFAQ articles pages – a simple raw example
Dear All
The use of QR Codes in web pages and advertises is growing: in the first case because the webmaster consider them useful or because he/she must follow the site user’s trend.
In this post we describe some steps to integrate a open source QR Code generator in a phpMyFAQ-driven site.
Please notice that the described strategy is not the best way to integrate QR Codes (or other barcode symbology) in phpMyFAQ pages - we are just showing a working example -, namely
- the QR Codes should be
- created just once - at record creation and record ID modification;
- stored in the FAQ database – preferably b64 encoded [1].
- The generator program should be placed in the phpMyFAQ directory tree – perhaps under the “/phpmyfaq/inc” folder.
- etc
Following these steps you may end up with a layout similar to
[attachment=1]pt20100201-20110811-02+03-w-qrcode-1+2.png[/attachment]
(see the attached file for a full screen version).
Components and locations
- phpqrcode (open source) – http://phpqrcode.sourceforge.net/
A simple PHP-based program – you may use others [2] - generator’s folder: at the web server root – /phpqrcode
- phpMyFAQ folder ; URL – /phpmyfaq ; http://faq.example.com/phpmyfaq/
- temporary file folder: at the web server root – /temp
- specially crafted phpqrcode file for phpMyFAQ – /phpqrcode/faq-qrcode.php
- FAQ’s URL format used – http://faq.example.com/phpmyfaq/?solution_id=1234 ([size=85]the most stable format among those that phpMyFAQ is currently able to generate[/size])[/*]
- Download the phpqrcode program from http://phpqrcode.sourceforge.net/
- Uncompress the downloaded file into the web server root (or to other place you have chosen).
- Apply the correct access rights to the resulting folder tree.
- If you don’t have a folder for temporary files create one (see above) and make sure it has the correct access rights.
- Place yourself at the program’s folder.
- Make a copy of the “index.php” file with the name “faq-qrcode.php” (or other you have chosen).
- Edit the “faq-qrcode.php” file in order to generate the QR Code image only by direct URL instructions.
- Edit the “artikel.tpl” phpMyFAQ template file and insert the URL instruction to generate the QR Code (see the example in the attached file)
At this point your pages should contain a QR Code image bellow the FAQ ID.
If you use rewrite instructions and prefer to encode the resulting long URL, make sure that it’s maximum size and character charset is within the QR Code symbology requirements.[3]
Footnotes
[1] You may use the data URI scheme “ data:image/png ” directly in the HTML page with this b64 encoded string.
- Example (at https://secure.wikimedia.org/wikipedia/en/wiki/Data_URI_scheme )
Code: Select all
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot">
- Barcode Writer in Pure PostScript (free - MIT/X-Consortium license)
https://www.terryburton.co.uk/barcodewriter/generator/ ;
https://code.google.com/p/postscriptbarcode/ - Zint (GUI and command line) The license type seems to have been changed
http://sourceforge.net/projects/zint/ ; - etc...
[4] Some pages that may be of your interest:
- QR code - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/QR_code ; - Data Matrix - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/Data_Matrix [an ISO standard];
[i]PDF417 - Wikipedia, the free encyclopedia[/i]
[size=85]http://en.wikipedia.org/wiki/PDF417 [a stacked linear barcode – ISO 15438][/size];[/*]
- ...
- full layout screenshots;
- the crafted “faq-qrcode.php” file for the generic example;
- “artikel.tpl” template edited lines.
Regards
2011-08-1
pt20100201
.
[attachment=0]pt20100201-20110811-qrcode-in-phpmyfaq-article.7z[/attachment]
Edited (2011-08-11): missing compressed attached file inserted. Our apologies.
.