|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Photon Smarty n00b
Joined: 25 Apr 2015 Posts: 3
|
Posted: Sat Apr 25, 2015 2:25 pm Post subject: [help] Plugin to change number in barcode |
|
|
Hello,
hello I am a french Prestashop CMS user using Smarty v3.
I would like an opinion on an issue.
I created a plugin to change a number (EAN/UPC code) in barcode.
in certain files tpl it works as desired.
I have a problem when the plugin is used in a template file that ultimately serves to generate a pdf. I have no errors, but the barcode is not displayed. If I call the variable (a number) unmodified it appears good.
here is the code of plugin modifier.barcode.php :
Code: | <?php
/**
* Smarty plugin
*/
function smarty_modifier_barcode($bc)
{
require_once('barcodes.php');
// include 1D barcode class
// set the barcode content and type
$barcodeobj = new TCPDFBarcode($bc, 'EAN13');
// output the barcode as HTML object
return $barcodeobj->getBarcodeHTML(1, 20, 'black');
} |
The code use tcpdf librairy.
I dont understand why the result is different in two template file (.tpl).
If someone can help me it would be cool, i'm not an expert. and Smarty documentation not helped me
Regards,
Chris |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Apr 26, 2015 4:07 am Post subject: |
|
|
This is not a Smarty problem.
I think for some reason the output of $barcodeobj->getBarcodeHTML(1, 20, 'black'); can't be converted to PDF. |
|
Back to top |
|
Photon Smarty n00b
Joined: 25 Apr 2015 Posts: 3
|
Posted: Mon Apr 27, 2015 9:14 am Post subject: |
|
|
thanks for your answer.
I thought the tpl file created an html output which itself was converted into pdf by TCPDF class.
the output of $barcodeobj generate a simple <div> element with a lot of <div> inside.
Do you think a smarty function could be better ? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Apr 27, 2015 6:11 pm Post subject: |
|
|
Again I think the problem is that TCPDF does not convert <div> element created by $barcodeobj->getBarcodeHTML(1, 20, 'black') to PDF.
It's not a Smarty problem. You should contact the authors of TCPDF. |
|
Back to top |
|
Photon Smarty n00b
Joined: 25 Apr 2015 Posts: 3
|
Posted: Tue Apr 28, 2015 8:02 am Post subject: |
|
|
ok, thank you.
I will keep my modifier to display barcodes in the website and look for other solution for pdf output.
regards. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|