- Posts: 45
- Thank you received: 2
Brand PDF before it can be downloaded
How can I include this in Hikashop deftly, so that a customer gets his branded PDF instead of the original file?
And additionally a probably more PHP affine question:
Very nice would be, if I could relinquish the "save"-function. But I think a download won't be possible without having the file saved first, right?
Please Log in or Create an account to join the conversation.
You can add your code in the function sendFile of the file administrator/components/com_hikashop/classes/file.php
As this is a direct modification of a core file of HikaShop, you will loose the modification when you update HikaShop so please make sure that you backup your modification.
Please Log in or Create an account to join the conversation.
Hi,
You can add your code in the function sendFile of the file administrator/components/com_hikashop/classes/file.php
As this is a direct modification of a core file of HikaShop, you will loose the modification when you update HikaShop so please make sure that you backup your modification.
thanks for this information!
do you think the feature is nice enough to be build in in hikashop in some later version? (is there a form for feature requests?)
Please Log in or Create an account to join the conversation.
However, it's a nice idea to trigger hikashop plugins when calling that function so that you can dynamically do some processing on it in a plugin, instead of having to modify a core file. We'll look at adding that in the near future.
Please Log in or Create an account to join the conversation.
Could you recommend me any easy instruction for this?
Please Log in or Create an account to join the conversation.
JPluginHelper::importPlugin( 'hikashop' );
$dispatcher =& JDispatcher::getInstance();
$do = true;
$dispatcher->trigger( 'onBeforeDownloadFile', array( & $file, & $do) );
if(!$do) return false;
that's what will trigger the plugins.
Then, you can create a hikashop plugin, like the plugins which already exist in the folder /plugins/hikashop/ of your website and implement the function onBeforeDownloadFile and put your code there.
Please Log in or Create an account to join the conversation.
this is my plugin code:
branding.xml
see: pastebin.com/9iuNE4SC for better readability
branding.php
see Pastebin - main part of a Hikashop plugin for branding sold PDFs
for better readability
A few more things:
- I wasn't in the mood to deal with GNU etc. So I removed author and licensing lines from the files. Feel free to use, modify and improve the code. But if you improve, please let me know.
- I finally included a reduced Zend Framework for PDF editing in the plugin. So it hasn't to be "installed" seperately.
- What for is the $do variable?
Please Log in or Create an account to join the conversation.
The $do variable allows you to cancel the download of the file by setting it to false.
Please Log in or Create an account to join the conversation.
thanks
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
thanks
Please Log in or Create an account to join the conversation.
pastebin.com/WgCvKNEK
Please Log in or Create an account to join the conversation.
thanks a lot for help
Please Log in or Create an account to join the conversation.
So it's more complex to do than what I thought first.
The best would be that @klimmbimm provides a zip of what he has done.
Please Log in or Create an account to join the conversation.
Best,
KB
EDIT: Found the zip and merged nicolas' changes to make it officially compatible with Joomla 2.5.
Please log in or register to see it.
To be honest, I didn't share the zip in the past, because I didn't (and still don't) have a clue about copyright stuff. E.g. I am using part of the Zend Framework to write to PDFs and the calibri.ttf.
REGARDING THE SUPPORTED JOOMLA VERSION: I am using the plugin with Joomla 2.5. By now, without the changes made by nicolas (thank you!). I guess, it would run under Joomla 3.x as well. Feel free to try and let us know.
REGARDING THE MISSING INDEX.HTML: It's like nicolas mentioned before. You need additional files. But you could remove at least calibri.ttf from the listing in the branding.xml file, if you like to fiddle around a bit.
Please take care to comment or remove the following line in branding.php
Please Log in or Create an account to join the conversation.