11
chefry
Re: QR Code Generator
  • 2013/2/5 15:13

  • chefry

  • Home away from home

  • Posts: 1005

  • Since: 2006/10/14


well, obviously it doesn't do what i want.

I have over 25,000 articles in publisher and I'm not going to go back and insert code into each one of them.

The help button in the admin side gives a 404 error

And I created a block to control where the QR Code should appear, now the block doesn't show in the Blocks admin section to edit or delete it.

It also doesn't appear in the module wide cache system under preferences-general

12
Anonymous
Re: QR Code Generator
  • 2013/2/5 15:38

  • Anonymous

  • Posts: 0

  • Since:


Oops, I see this google function is deprecated now...

13
Peekay
Re: QR Code Generator
  • 2013/2/5 18:42

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


As far as I can see, to use the QR Code module you would just need to adapt the PHP file of Publisher that sent the article to the Smarty template. First, you would include the qrcode file:

include_once XOOPS_ROOT_PATH."/modules/qrcode/qrcode.php";


Then add this code:

//Visit website
$data = array();
$type "url";
$data['url']="http://www.example.com";
$size="250"// image will be 250x250px
echo qrcode($type,$data,$size);


However, in place of "http://www.example.com" you would grab the article URL, pop it into a variable and use the variable instead of the URL. Each article the user views will have a different URL which should be automatically embedded in the QR code.

Instead of the echo statement, you would send the output to the Smarty template, or add the echo statement to the template and pull the variables from the PHP file.

I don't use Publisher, but I'm sure someone who knows it could post some real-world code to show how that might work.

14
Peekay
Re: QR Code Generator
  • 2013/2/5 21:21

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


I am on a laptop with no Xoops install, but trawling code from a module download of the 'News' module I would say you need to do something like this. In 'article.php' you would add:

$data=array();
$type="url";
$data['url'] = '.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid().'';
$showmetheQRcode= qrcode($type,$data);


Then, where the template assignments are made, normally lower down the page:

$xoopsTpl->assign('showmetheQRcode'$showmetheQRcode);


Then, in the template file (news_article.html)

<div><{$showmetheQRcode}></div>


I cannot test this and I'm sure there will be a missing quote mark somewhere that will stop it working, but that's the general idea, I think

This is obviously not an 'out-of-the-box' solution, but perhaps the developer will publish some specific code examples for the more popular Xoops modules to help get people started.

15
chefry
Re: QR Code Generator
  • 2013/2/5 21:50

  • chefry

  • Home away from home

  • Posts: 1005

  • Since: 2006/10/14


I was hoping Trabis would read the thread,

How about it Trabis, can you give us a quick fix?

16
trabis
Re: QR Code Generator
  • 2013/2/6 0:24

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:
chefry wrote: I was hoping Trabis would read the thread, How about it Trabis, can you give us a quick fix?
I don't have time to implement this on publisher. I may do it for the 2.6.0 version and using the qrcode module that is in the core. For a quick fix let us try following Peekay example. Edit item.php and search for:
$xoopsTpl->assign('item'$item);
It should be on the bottom of the file. Before that line try to add this code:
//start of hack
if (file_exists($file XOOPS_ROOT_PATH "/modules/qrcode/qrcode.php")) {
    include_once 
$file;
    
$data = array(
        
'title' => $itemObj->getVar('title'),
        
'url'   => $itemObj->getItemUrl(),
    );
    
$size "250"// image will be 250x250px
    
$item['qrcode'] = qrcode('url'$data$size);
}
//end of hack
$xoopsTpl->assign('item'$item);
I never used qrcode so I don't know what data it accepts. I've added the 'title' but I have no idea if it will be read/added or not. Now in the publisher_item.html template you should be able to use this line for displaying the qrcode:
<{$item.qrcode}>
Not tested.

17
chefry
Re: QR Code Generator
  • 2013/2/6 8:16

  • chefry

  • Home away from home

  • Posts: 1005

  • Since: 2006/10/14


So, Trabis... if I wanted to put it after the main text box and right before the "Navigate through the articles", where would i put it in the publisher_item.html file?

18
Mamba
Re: QR Code Generator
  • 2013/2/6 8:22

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


Chefry, try to experiment a little, so you can learn something from it

Trabis is very busy with XOOPS 2.6.0, so we can help him (and XOOPS) by avoiding asking him for every little thing.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

19
chefry
Re: QR Code Generator
  • 2013/2/6 12:06

  • chefry

  • Home away from home

  • Posts: 1005

  • Since: 2006/10/14


ok Trabis, I got it to appear on the page where i want, but it's not picking up on the title when you read the qr code, only the url. But that might be a problem with the QR code module and not the code you gave me above.

Mamba was the submitter for that module, so maybe he can enlighten us. How can we get the title to appear when you scan it, with the URL embedded so you just have to click on the title to go to the webpage?

If anyone has a tablet PC, maybe they can go to franksrecipes.net and test it for me

20
Peekay
Re: QR Code Generator
  • 2013/2/6 14:06

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Try changing:

$item['qrcode'] = qrcode('url'$data$size);


to:

$item['qrcode'] = qrcode('txt'$data$size);


Basically, if you want both text and a URL in the QR, the QR 'type' needs to be text (txt). You may also need to add a non-breaking space between the title and the URL values stored the array, but I am not sure how to do that in an array. I would just concatenate the two variables, but I'm old school!

In essence you're aiming for:

$data = array();
$type "txt";
$data['txt']= (The title variable a space the article url) ;
echo 
qrcode($type,$data);

Login

Who's Online

181 user(s) are online (118 user(s) are browsing Support Forums)


Members: 0


Guests: 181


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits