It would be spiffy if you could auto-generate QR codes for shurls using the functionality provided by the Mobile Codes module. I am doing this at http://ayl.lv via a hook_form_FORM_ID_alter() in a custom module (go there and create a shurl to see it in action) and a custom Views template file (see screenshot below).
![]()
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | Untitled.png | 10.43 KB | LeeHle |
| #1 | qr-codes.jpg | 71.43 KB | john bickar |
Comments
Comment #1
john bickar commentedOops forgot that d.o. doesn't like inline images.
Comment #2
jjeff commentedThat is soooooo cool!
Do you have any code you can share? What did it take to get this working?
Can you share your hook_form_FORM_ID_alter()?
Comment #3
john bickar commentedWell, shurly:
And the Views template is views-view-field--shurly-my-urls--source-1.tpl.php (the added View field for QR code is a shurly: short url, output as a full URL with base path, not formatted as a link):
Probably better ways to do it but this was Q&D.
Comment #4
RAINFIRE commented. . . or use the google api.
Add another Global: Custom text and label it QR Codes after the 'Links' and use this example to let google create them. In the Text: box put this:
Working example here: http://ez.vg/
Comment #5
deciphered@RAINFIRE,
That approach neither caches it, or will work offline. While Mobile Codes 1.x doesn't work offline, 2.x (currently in development) does provide the ability to use your own offline QR Code generator.
Comment #6
carl.brown commentedMassive Kudos to John Bickar for posting that snippet. A big help. Thanks!
Comment #7
jschrab commentedFor the benefit of others, Drupal 7 theme() calls are slightly different. Here's a simple example of what worked for me:
<?php print theme('mobilecode',array('data' => $output, 'attributes' => array('#preset' => 'small'))); ?>Comment #8
bserem commented@jschrab could you please tell us where you used this?
thnx
Comment #9
deciphered@jschrab,
It's entirely up to you on your personal needs for where you would use that or similar code, put given the fact that he is 'print'ing the code then it's likely that it's in a .tpl.php file somewhere.
Comment #10
LeeHle commentedJohn Bickar could you help me I'm trying to achieve the exact same thing as in the attachment... I'm a newbie and I'd appreciate step by step help on how to get the same results you have on Drupal 7 though :). So far this is what i haveComment #11
LeeHle commented@John Bickar could you help me I'm trying to achieve the exact same thing as in the attachment... I'm a newbie and I'd appreciate step by step help on how to get the same results you have on Drupal 7 though :). So far this is what i have
Comment #12
jschrab commentedI added a field to the View so that my template override for that column could call theme('mobilecode'...)
1. Add a field to your View to expose the URL 'Short URL' is the field you are looking for and "Output full URL including base path" is the option to check.
2. Look under "Theme->Other->Information" in the View display editor. Look up the tpl filename suggestion of the new field you've added. Create that .tpl file in your theme, then add that theme('mobilecode'...) code into the tpl file. Rescan Template Files.
I'm skimming just details but that's generally it.
Comment #13
LeeHle commentedThank you... let me try that :)
Comment #14
LeeHle commentedthank you so much i got it to work @jschrab
Comment #15
jibus commentedSince it's possible to achieve this by a custom template, i guess it is not a feature request anymore.
Update the category issue.
Comment #16
jibus commentedClosing issue