|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
michielh Smarty n00b
Joined: 15 Aug 2009 Posts: 4
|
Posted: Sat Aug 15, 2009 3:54 pm Post subject: Smarty urlExists timeout |
|
|
Hi guys, sorry for doing this but I must have created two posts before I can post my real question. This is the first one.
Last edited by michielh on Sat Aug 15, 2009 3:56 pm; edited 1 time in total |
|
Back to top |
|
michielh Smarty n00b
Joined: 15 Aug 2009 Posts: 4
|
Posted: Sat Aug 15, 2009 3:54 pm Post subject: |
|
|
And this is the second one. Really sorry. |
|
Back to top |
|
michielh Smarty n00b
Joined: 15 Aug 2009 Posts: 4
|
Posted: Sat Aug 15, 2009 3:54 pm Post subject: |
|
|
Hi guys, I'm looking at a timeout error and although I've searched everywhere, I cannot find a way to fix it in Smarty. Here's my problem:
A foreach-loop implemented in a template to list personal details makes use of the following code to determine whether or not a picture of the member is available on the server:
Code: |
{urlExists url="`$smarty.const.BASE_HREF`data/members/`$member.memberid`.jpg"}
{if $urlExists}
<img src="data/members/{$member.memberid}.jpg" alt="{$member.name}" title="{$member.name}" />
{else}
<img src="images/nophoto.jpg" alt="{$member.name}" title="{$member.name}" />
{/if}
|
With this code still active, a server timeout occurs after the 19th member cycle. The other 20 members aren't even being displayed on the page. But when I remove the code, the page is displayed within 2 seconds. Is there a better (and less resource consuming ) way to attach the default 'nophoto.jpg' picture to members without one?
Thanks in advance for the help!
Michiel |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Aug 15, 2009 3:58 pm Post subject: |
|
|
Testing if a URL exists is not a very good way to determine if they have a photo or not. I'd use a database entry or something. Testing if a URL exists requires network latency on each test, and will timeout if it cannot make a connection for any reason. |
|
Back to top |
|
michielh Smarty n00b
Joined: 15 Aug 2009 Posts: 4
|
Posted: Sat Aug 15, 2009 4:23 pm Post subject: |
|
|
Thanks for your swift reply, mohrt.
If I would have build the website from the ground up I would indeed have added a check (for instance a boolean value) to the userdetails table in order to see if the picture is in place. However, the previous developer has left and I cannot make changes to the database structure he has created. It would make things too difficult.
Thanks for the advice, I have deleted the ifExists code and replaced it with the following:
Code: |
<img src="data/members/{$member.memberid}.jpg" width="150" height="200" style="background-image:url(images/nophoto.jpg);"/>
|
And even though Iexplore users see a small cross at the top left corner of the image, I think it's ok.
Thanks for helping me out, michiel |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|