Vox Populi(x) forum

Alexandria Book Library => Richieste (Requests) => Topic started by: JorgeAnzola on 11 April 2015, 18:57:47

Title: Automatic QR instead of cover image.
Post by: JorgeAnzola 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

<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 (http://stackoverflow.com/questions/29579564/set-current-url-string-in-img-src)'s the Stackover post with the codes I've used.

Any help would be appreciated.
Title: Re: Automatic QR instead of cover image.
Post by: JorgeAnzola on 11 April 2015, 18:59:52
I haven't made***
Sorry for any other misspelling.
Title: Re: Automatic QR instead of cover image.
Post by: federica 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
Title: Re: Automatic QR instead of cover image.
Post by: JorgeAnzola on 13 April 2015, 23:35:59
Hi! I made it. If anyone else is interested, I put this:

<?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


<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.
Title: Re: Automatic QR instead of cover image.
Post by: federica 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