Jump to content

Check a URL in smarty?


mohsart

Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...