Here with the wrong code :
Profile module
https://www.monxoops.fr/modules/profile/userinfo.php?uid=2
Search page
https://www.monxoops.fr/search.php?query=xswatch4&action=results&lang=english
When all will be ok, I will propose my templates.
zyspec wrote:
The file you're checking for must be a path, not a URL. So chaine_surcharge should be something like:
/var/www/html/themes/mx-theme/modules/xmnews/assets/images/xmnews_search.png
use something like XOOPS_PATH, not XOOPS_URL to build the file location.
<{assign var="chaine_surcharge" value=$xoops_imageurl|cat:"modules/"|cat:$result.image|replace:"$xoops_url/modules/":''}>
chaine_surcharge : <{$chaine_surcharge}> <br />
<{if file_exists($chaine_surcharge)}>
<div class="d-inline"><img src="<{$chaine_surcharge}>" alt="<{$module.name}>"> <a href="<{$result.link}>"><{$result.title}></a></div>
<div class="d-none d-md-inline "><span class="fas fa-calendar fa-sm ml-2"></span> <{$result.time}></div>
<br />
<{else}>
<img src="<{$result.image}>" alt="<{$module.name}>"> <a href="<{$result.link}>"><{$result.title}></a> (<{$result.time}>)<br />
<{/if}>
In smarty, you cannot use file_exists() on a URL, but you can use it on a local file
I think, the best way is to check in your controller.
<{$file_headers = @get_headers($chaine_surcharge)}>
file_headers = <{$file_headers}> <br />
file_headers =
<{if file_exists($chaine_surcharge)}>
<div class="d-inline"><img src="<{$chaine_surcharge}>" alt="<{$module.name}>"> <a href="<{$result.link}>"><{$result.title}></a></div>
<div class="d-none d-md-inline "><span class="fas fa-calendar fa-sm ml-2"></span> <{$result.time}></div>
<br />
<{else}>
<img src="<{$result.image}>" alt="<{$module.name}>"> <a href="<{$result.link}>"><{$result.title}></a> (<{$result.time}>)<br />
<{/if}>
<{assign var="chaine_surcharge" value=$xoops_imageurl|cat:"modules/"|cat:$result.image|replace:"$xoops_url/modules/":''}>
http://xoops-tests2.local/themes/mx-theme/modules/xmnews/assets/images/xmnews_search.png
<{assign var="chaine_start" value="$xoops_url/modules/"}>
chaine_start = <{$chaine_start}> <br />
<{assign var="chaine_surcharge" value=$xoops_imageurl|cat:$result.image|replace:$chaine_start:''}>
chaine_surcharge = <{$chaine_surcharge}> <br />
chaine_start =http://xoops-tests2.local/modules/
chaine_surcharge =http://xoops-tests2.local/themes/mx-theme/xmnews/assets/images/xmnews_search.png
<li>
<{assign var="chaine_start" value="$xoops_url/modules/"}>
<{assign var="chaine_surcharge" value=$xoops_imageurl|cat:$result.image|replace:$chaine_start:''}>
<{if $chaine_surcharge}>
<img src="<{$chaine_surcharge}>" alt="<{$module.name}>"> <a href="<{$result.link}>"><{$result.title}></a> (<{$result.time}>)
<{else}>
<img src="<{$result.image}>" alt="<{$module.name}>"> <a href="<{$result.link}>"><{$result.title}></a> (<{$result.time}>)
<{/if}>
</li>
<{if $chaine_surcharge}>
<a data-lightbox="image-1" data-title="Gallery" href="https://www.invitahome.com/uploads/images/img615fd7bfe4885.jpg">
<img class="img-responsive" alt="" src="https://www.invitahome.com/modules/publisher/assets/images/default_image.jpg" data-echo="https://www.invitahome.com/uploads/images/img615fd7bfe4885.jpg" />
</a>