Jump to content

FieldtypeQRCode


monollonom
 Share

Recommended Posts

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

qr-codes.png

Link to comment
Share on other sites

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.

  • Like 3
Link to comment
Share on other sites

  • 4 weeks later...

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!

  • Like 3
Link to comment
Share on other sites

  • 1 year later...

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);

 

  • Thanks 1
Link to comment
Share on other sites

  • 8 months later...

@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)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...