i want to do something like this
{if image_exists}
<img src='{$path}{$imagename}'>
{else}
<img src='{$path}default.jpg'>
{/if}
how do i solve this issue?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Rather than having Smarty doing the logic, I’d say it’s better to have the actual PHP doing it instead.
In PHP you can do something like:
Then in the template you won’t need any
ifstatement. Simply use theimgtag as you would normally.If you really want to do the check in the template file, just use the PHP function normally with Smarty’s
ifstatement.