Great module by the way - I'm trying to apply an imagecahce preset to the qr code and it doesn't seem to be doing anything. I've several presets, but it has no affect on the qr image.

Comments

whartwell’s picture

Same problem here. QR generates fine in the block but the preset doesn't apply. Any suggestions?

ice5nake’s picture

I am having similar problems. How are you applying the preset? What is the code you are using?

I can't get the height or width settings to work.

Here's the code I tried inside of a View field template

print theme('qr_codes', $output, 150, 150);

The QR code image displays but the size varies. The $output variable is a URL. Also, I can't find documentation on usage for this module. Any help would be appreciated.

windm’s picture

Hi there,

(although being not familiar with PHP at all) I would like to integrate the QR Code (containing the [node-url] token) in the
a) Content-Template for several Content Types
b) print.tpl.php for the "printer-friendly-view" managed by the print module

I used the print theme('qr_codes', $output, 150, 150); in both cases and got a QR Code displayed (with the correct size) but it does not contain any link or content.

The QR-Code-Block (provided by the qr_code module) is configurable - so I defined [node-url] as the content of the block and it works fine.

But how do I get that [node-url] into QR-Code for the content-template and the print.tpl.php ?

windm’s picture

OK - I think I solved the issue (post #3) - maybe it´s a workaround but it works:

print theme('qr_codes', 'http://www.yoursite.com/' . $node->path, 150, 150);

Due to the fact that I didn´t find a replacement for $node->path that would hand over the enire URL, I use this combination of a hardcoded URL + the current path.
Reading other threads, the $node->path seems to be only available for auth users - doesn´t matter for my special case but is maybe important for others.

I´m still curious if there is a better solution - something like "$node->source_url" or something that could use the token [node-url] which works fine in the QR-Block provided by the module.

ice5nake’s picture

I am using a View field template views-view-field--signs--page-1--path.tpl.php

The name of the field in the View is path.

Most of the images are getting output with a width of 99 pixels. This is really driving me crazy. :)

Perhaps an important piece of information is that I am using libqrencode.

IncrediblyKenzi’s picture

FYI, instead of hardcoding your URL, you can use the drupal global $base_url to achieve this.

I'm not sure if there's a token available for absolute URL in Drupal 6, but will take a look.

IncrediblyKenzi’s picture

Looks like there are several tokens that should do this, including node-url:

./token.module: $values['current-page-url'] = url($_GET['q'], array('absolute' => TRUE));
./token_node.inc: $values['node-url'] = url('node/' . $node->nid, array('absolute' => TRUE));

so either node-url or current-page-url should return an absolute path.

IncrediblyKenzi’s picture

windm: The reason your tokens aren't working is because the token replace happens in the block view code, not in the theme layer. You'll need to invoke the token replace yourself:

   // use token replacement if available for nodes and users
   $tokens = module_exists('token');
   global $user;
   if (arg(0) == 'node' && is_numeric(arg(1)) && $tokens) {
     $data = token_replace($data, 'node', $node);
   }
   if($tokens && $user->uid) {
     $data = token_replace($data, 'user', $user);
   }
   print theme('qr_codes', $data, 150, 150); 

newToo: Just realized this thread was hijacked.. I'll take a look at the imagecache code.

pitolek’s picture

Hi there,

had sort of the same problem. Found that the hook_theme function declares the following:

function qr_codes_theme() {
  return array('qr_codes' => array(
    'arguments' => array('data' => NULL, 'width' => NULL, 'height' => NULL, 'margin' => NULL, 'imagecache_preset' => NULL, 'attributes' => NULL)
  ));
}

However, the actual theming function uses different parameters:
function theme_qr_codes($data, $width = 150, $height = 150, $margin = 0, $alt = '', $title = '', $imagecache_preset = '', $attributes = array()) {

Removing the $alt and $title from the parameters results in the chosen imagecache preset being used.

Hope this helps ...

borjagut’s picture

I've a similar problem, but using the block.

If i write a 'static' string, it works perfectly, but when i'm using a token value, it doesn't work.

Then, I use the theme_qr_codes function in my tpl, but the same problem, with strings is great, but with a variable, i.e. $title (simpler impossible), doesn't return something.

Any ideas?

any help would be apreciated, and sorry for my english

Updated:

I'm using the module in a page where I need to use a lot of cache features, could be that the problem? Any solution?

SOLUTION: The problem were the blank spaces of the token

ice5nake’s picture

I was trying to add an alt tag to the image but I noticed the same thing as pitolek. Shouldn't the arguments match?