Leap-IT Posted October 30, 2014 Share Posted October 30, 2014 (edited) Ok this is just to share a small piece of code i did (nothing exceptional) that makes it easy to add attachments to my products. this little code looks for a file with the same name as the product reference. if it exsists then it adds an icon (found in img/pdf.png) see picture for results. rules: 1. I only have one attachment per product (might change this in near future) 2. each product is multilanuage so i add suffix to my file name before the extention like this for french '_fr' for english '_en' and so on so a file called 'myfile.pdf' becomes 'myfile_fr.pdf' i place all my PDF files into a folder under the root like so : www.mydomaine/pdffiles/myfile_fr.pdf .... then in themes/default-bootstrap/product.tpl i added this near line 227 <---usefull links--> <!-- usefull links--> <ul id="usefull_link_block" class="clearfix no-print"> <li> {$lang_checker = {"_"|cat:{$lang_iso[spam-filter]} {$filename = "pdffiles/{str_replace(,'/','-',$product->reference)}{$lang_checker}.pdf"} {if file_exists($filename)} <div > <a target="_blank" href="{$filename}"><img src = "img/icon/pdf.png" width="100px"></a> </div> {/if} </li> </ul> you might notice that i did a replace '/' with '-' this is because my products codes are something like 'trr/010598G so i just replaced the '/' with something more convienient for the file names. Edited October 30, 2014 by Leap-IT (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now