Im trying to declare a variable,
I can’t get the syntax right and am not sure what it is even meant to be. This is for a magento installation… but it’s just a general PHP problem.
What I want this to do, is when an item page loads, it checks to see if there is a file matching the SKU exactly + ‘.pdf’, as it’s a PDF file, and if there is one, to attach it to the product page… and if there isn’t, display an email address.
Here is my code:
<?php $filename = 'echo $this->htmlEscape($_product->getSku()).pdf; if (file_exists($filename)) { ?>To download the PDF SPEC SHEET, please click here
<?PHP } else { ?>No Spec Sheet exists for this item. Please email us to request one.
<?PHP } ?>It’s mainly the “$filename = 'echo $this->htmlEscape($_product->getSku()).pdf;” part I think… I’ve had it breaking and ‘loading’ front-end but it never works properly.
This code: ‘click here’ works perfectly.
I can make a permanent link… my only trouble is defining $filename and possibly the if statement… but I do think it;s probably just defining the $filename.