Roych Posted January 25, 2022 Posted January 25, 2022 Hello Not sure why but it always shows me two qrcodes (images -> gif) next to each other on the page. Can't see the problem in my code. Any ideas? I have a select-options field with option to show the qr-code or not. If selected It always shows two qr-codes. This happened after the upgrade of the module actualy it was working fine before!! My code <?php if ($item->id == '3') : ?> <div class="qrkoda"><?=$page->qr_koda?></div> <?php else:?><?php endif;?> Thank you R
monollonom Posted January 26, 2022 Author Posted January 26, 2022 Hi, Sorry about this issue. Do you have multi-language activated on your website ? Also, which field(s) do you show with this qrcode ?
monollonom Posted January 26, 2022 Author Posted January 26, 2022 After doing a quick check I assume that was it (multilang issue). Here's a new version that will only output the QR Code in the user's language if it's a guest. Please note you'll still have the two QR Codes if you're logged in. I will think of something to help with the output, something like a ->get() to output a specific source and/or language. 3
Roych Posted January 26, 2022 Posted January 26, 2022 5 hours ago, monollonom said: Here's a new version that will only output the QR Code in the user's language if it's a guest. Please note you'll still the two QR Codes if you're logged in. Thank you, it's working now. As you'we stated above, showing two when logged in. ? R
Sava Posted February 23, 2022 Posted February 23, 2022 Thank you for a great module, I am just wondering how do I get URL to create a download link? ?
monollonom Posted February 24, 2022 Author Posted February 24, 2022 Hi @Sava, I'm not sure I get your question... do you want to know how to get a URL of the QR code to be able to download it ? In the unformatted output the QR code is already in the form of an <img> (or <svg>), but I went ahead and added a "raw" key in the unformatted output. You can download the latest version and try to do something like... $qrcode = $page->getUnformatted("qrcode_field"); foreach($qrcode as $qr) { $filename = $sanitizer->snakeCase($qr["label"]); $label = "Download QR code for \"{$qr["label"]}\""; echo "<a href=\"{$qr["raw"]}\" target=\"_blank\" download=\"$filename\">$label</a>"; } Hope this helps! 3
Sava Posted February 25, 2022 Posted February 25, 2022 Sorry for the unclear question but your answer @monollonom was exactly what I need. Thank you 1
psy Posted December 4, 2024 Posted December 4, 2024 Using v1.0.14 which fixes a problem for multi-language sites. Unfortunately it breaks single language sites as it assumes multi-language support is installed. Fix for me was: public function ___wakeupValue(Page $page, Field $field, $value) { $field = $field->getContext($page); $this->svg = $field->get("format") !== "gif"; $this->markup = $field->get("markup") === 1; $user = $this->user; $languages = null; if(wire('modules')->isInstalled("LanguagesSupport")) $languages = $user->isGuest() ? [$user->language] : $page->getLanguages(); $sources = $this->parseSources($page, $field); return $this->generateQRCodes($page, $sources, $languages); 1
monollonom Posted December 5, 2024 Author Posted December 5, 2024 Hi @psy, Thanks for raising this issue and providing a fix. This was an oversight from me, sorry about this. I just pushed the fix! Let me know if you have any other issue. 1
Laksone Posted August 16, 2025 Posted August 16, 2025 @monollonom Thank's for the Module, works great.🙂 However it seems I just discovered a bug. I am trying to generate a VCARD QR Code based on a textarea content. This is the content of the textarea for example: BEGIN:VCARD VERSION:3.0 FN:Lorem ipsum dolor sit amet ORG:Company name here lorem ipsum TEL;TYPE=WORK,VOICE:+491234567890 TEL;TYPE=CELL: EMAIL:info@lorem-ipsum-dolor.de URL:https://lorem-ipsum-dolor.de/ ADR;TYPE=WORK:;;Address;Loremipsum Street;;12345;Deutschland END:VCARD After saving it's breaking the backend page with an error and makes the page unaccessible: Error: code length overflow. (2204>152)
monollonom Posted September 5, 2025 Author Posted September 5, 2025 Hi @Laksone, Sorry but somehow I forgot to have a look at it. I managed to update the QR code generation to accomodate for bigger content but there is still a limit to this so I added a note in the README and in the fieldtype’s "Details" tab. I also took on the opportunity to do some code cleanup and add the option to set the (interesting) error correction level. Please update the module and let me know if you’re facing any issues.
monollonom Posted July 28 Author Posted July 28 I just published a new update (1.2.0) that allows to tweak the appearance of the QR code to your likings, with the ability to set a module’s (one of the small square) size in pixels, change the foreground and background colors, or even set the background to be transparent. I also updated the readme with more informations or you can have a look at the code to learn more. 2
monollonom Posted July 29 Author Posted July 29 Hi everyone, I once again updated the module (v2.0.0) but this time with a potential breaking change for those hooking into one of the module’s methods. I had to change the hookable methods’ signature to provide the field generating a QR code so hooks can check against the field’s name. Since the field has been placed as the second argument of all hookable methods, if you were relying on indexes to access arguments in your hooks rather than names, e.g. $event->arguments(1) instead of $event->arguments("options") for FieldtypeQRCode::getQRText, then it will break. I should have added the field right at the beginning but it’s only now that I have the need for the following use-case: When generating multiple (and potentially large) QR codes it can be quite expensive and slow down the page rendering, so to speed things up consider adding the following hooks to cache the output: $wire->addHookBefore("FieldtypeQRCode::generateQRCodes", function(HookEvent $event) { /** @var Field $field */ $field = $event->arguments("field"); /** @var Page $page */ $page = $event->arguments("page"); $qrcodes = $page->meta()->get("qrcodes-{$field->name}"); if(!empty($qrcodes)) { $event->return = json_decode($qrcodes, true); $event->replace = true; } }); $wire->addHookAfter("FieldtypeQRCode::generateQRCodes", function(HookEvent $event) { /** @var Field $field */ $field = $event->arguments("field"); /** @var Page $page */ $page = $event->arguments("page"); $page->meta()->set("qrcodes-{$field->name}", json_encode($event->return)); }); $wire->addHookAfter("Page::saved", function(HookEvent $event) { /** @var Page $page */ $page = $event->object; foreach($page->fields->find("type=FieldtypeQRCode") as $field) { $page->meta()->remove("qrcodes-{$field->name}"); } });
adrian Posted July 30 Posted July 30 Thanks for the updates @monollonom - I am curious though. I am using: $p = $event->arguments[0]; in a FieldtypeQRCode::getQRText hook and it still seems to be working fine. Am I not understanding what the changes are supposed to have broken?
monollonom Posted July 31 Author Posted July 31 18 hours ago, adrian said: Thanks for the updates @monollonom - I am curious though. I am using: $p = $event->arguments[0]; in a FieldtypeQRCode::getQRText hook and it still seems to be working fine. Am I not understanding what the changes are supposed to have broken? Actually my example is a bit misleading, sorry about this. I added the field as the second argument in all three hookable methods so in your case it's perfectly fine but say you tried to change the `options` argument of FieldtypeQRCode::getQRText by getting it using `$event->arguments(1)`, then it would break. I hope it makes sense and I'll update my post above. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now