mohsart Posted June 19, 2010 Share Posted June 19, 2010 I have code like this {if $product->supplier_reference} supplier_reference}.html#review" target="_blank">gobooks.nemir.org {l s='(May result in a error if book does not exist on that webpage)'} {/if} that show a link to a website that has revews on many (but not all) of the books that I sell.So, I'd like to check if the page exists and only show the link if it does. Is this possible?Edit: code broke of course, but I think my point is clear enough/Mats Link to comment Share on other sites More sharing options...
rocky Posted June 20, 2010 Share Posted June 20, 2010 I think you can use code like the following in product.tpl: {if $product->supplier_reference AND file_exists($product->supplier_reference|cat:'.html')} You may need to add a path before the filename for it to work though. Link to comment Share on other sites More sharing options...
mohsart Posted June 20, 2010 Author Share Posted June 20, 2010 Sorry if I was unclear, it's a URL on a remote website that I want to check.I tried some variations of entering the URL in file_exists() but I suspect that it only works for local files?/Mats Link to comment Share on other sites More sharing options...
rocky Posted June 20, 2010 Share Posted June 20, 2010 You are right that file_exists only works for local files. I tried using fopen to check whether the file exists, but I can't get it to work with Smarty. I think you'll need to write code to check whether the file exists in product.php and then pass in the variable only if it exists. Link to comment Share on other sites More sharing options...
mohsart Posted June 20, 2010 Author Share Posted June 20, 2010 Ok, thanks/Mats 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