Author Topic: Automatic QR instead of cover image.  (Read 1491 times)

JorgeAnzola

  • Guest
Automatic QR instead of cover image.
« on: 11 April 2015, 18:57:47 »
That would be very cool. I'm trying to do that with goqr.me API, wich creates a QR with a given URL. I'm trying to get current URL and put in a <img> tag. And put the code here

Code: [Select]
<div class="cover<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>">
<!-- here -->

    Automatic generated <img> code

<!-- here -->
                </div>

I haven't make it because I'm not that good in PHP programming. Here's the Stackover post with the codes I've used.

Any help would be appreciated.

JorgeAnzola

  • Guest
Re: Automatic QR instead of cover image.
« Reply #1 on: 11 April 2015, 18:59:52 »
I haven't made***
Sorry for any other misspelling.

Offline federica

  • Amministratore
  • Delfino
  • *****
  • Posts: 958
  • Karma: +1/-0
Re: Automatic QR instead of cover image.
« Reply #2 on: 13 April 2015, 09:46:10 »
Hi JorgeAnzola,
if you need to get the current url I suggest to see this guide http://webcheatsheet.com/php/get_current_page_url.php
Al mondo ci sono 10 tipi di persone, quelli che hanno capito il codice binario e quelli che non l'hanno capito.
http://www.antivirushelp.it
stacca la spina!

JorgeAnzola

  • Guest
Re: Automatic QR instead of cover image.
« Reply #3 on: 13 April 2015, 23:35:59 »
Hi! I made it. If anyone else is interested, I put this:

Code: [Select]
<?php 
function getUrl() { 
    
$url1  = @( $_SERVER["HTTPS"] != 'on' ) ? ''.$_SERVER["SERVER_NAME"] :  ''.$_SERVER["SERVER_NAME"]; 
    
$url1 .= $_SERVER["REQUEST_URI"]; 
    return 
$url1;

?>

<center>
<img src="http://api.qrserver.com/v1/create-qr-code/?size=70x70&data=<?= getUrl(); ?> ">
<a href="http://api.qrserver.com/v1/create-qr-code/?size=600x600&data=<?= getUrl(); ?>">Descargar código QR</a>
</center>

in here

Code: [Select]
<h2><?php echo $this->book->title;?></h2>
<h4><?php echo $this->book->subtitle;?></h4>
<div class="booktab<?php echo $this->escape($pageClass); ?>">
<div class="cover<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>">
<!-- FROM HERE -->

<?php 
function getUrl() { 
    
$url1  = @( $_SERVER["HTTPS"] != 'on' ) ? ''.$_SERVER["SERVER_NAME"] :  ''.$_SERVER["SERVER_NAME"]; 
    
$url1 .= $_SERVER["REQUEST_URI"]; 
    return 
$url1;

?>

<center>
<img src="http://api.qrserver.com/v1/create-qr-code/?size=70x70&data=<?= getUrl(); ?> ">
<a href="http://api.qrserver.com/v1/create-qr-code/?size=600x600&data=<?= getUrl(); ?>">Descargar código QR</a>
</center>
<!-- TO HERE -->
                </div>

In the file components/com_abook/views/book/tmpl/default.php. BUT friendly URLs have to be activated.

Offline federica

  • Amministratore
  • Delfino
  • *****
  • Posts: 958
  • Karma: +1/-0
Re: Automatic QR instead of cover image.
« Reply #4 on: 16 April 2015, 12:42:38 »
Instead of getUrl() you could try to use the function you can see here http://webcheatsheet.com/php/get_current_page_url.php
Your function is not complete, for these reason is working only the SEF is enabled
Al mondo ci sono 10 tipi di persone, quelli che hanno capito il codice binario e quelli che non l'hanno capito.
http://www.antivirushelp.it
stacca la spina!