Sublime directory Surf the web anonymous Pagerank Monitor


If Exist in a CMS Environment?

YMC
Thu 8 May 2008, 06:04 pm GMT +0200
Not sure if this is a Smarty issue or a PHP issue so I put my question here. Anyway...

I've taken one of my directories and changed scripts and redid the layout. One of the new options in the script is to showcase 5 new and 5 random listings. I've changed the plugin to show only one of each of these. I've also changed it to show the picture associated with the listing. The problem is that those listings that I am adding myself do not have a picture ( screenshots as well as other images are copyrightable and I only want to use pictures with the permission of the site owners and it is also a way to slightly reward the folks who come to me vs the ones I seek out myself.)

It's fairly easy to figure out the record number of each listing so I've named the picture files xxx.jpg where xxx is the record number.

One of the programmers for the script has created this elaborate function and has tried twice now to get this to work. The function does not appear to be working right and I keep thinking that the programmer is doing something like the Hello program joke that Samiotis posted.

Any ideas or suggestions? It just seems like this should be something that could be done in a line or two of code rather than creating external functions.

If xxx.jpg exist then display
else no display
/if

Is it really as complicated as this programmer is making it? I'm beginning to wonder if the best thing to do at this point is to create a 1px jpg for the listings without pictures and use that to have an actual picture to display.

Nikolas
Thu 8 May 2008, 10:48 pm GMT +0200
This is easy to accomplished. Use a code like this :

 
if ( file_exists('path/to/' $filename) ){
 
//show the image here
}
?>

YMC
Fri 9 May 2008, 12:36 am GMT +0200
Thank you for the code Nikolas. It is giving me an error which I suspect is because I am not using it properly.

[blockquote]

if ( file_exists('http://www.petsiteguides.com/site-thumbs/{$new_listing.id}.jpg) ){
 <img src="http://www.petsiteguides.com/site-thumbs/{$new_listing.id}.jpg" alt="{$new_listing.title|replace:"&":"and"}" />
}

[/blockquote]

$new_listing.id holds the record number

Where did I go wrong?

Nikolas
Fri 9 May 2008, 02:09 pm GMT +0200
You are messing php code with smarty code. The fragment I wrote is in php. So you need to use something like :

{php}
code fragment
{/php}

In this fragment, variables should be used as php variables. So instead of {$new_listing.id} you should probably use $new_listing->id

rana99
Mon 10 November 2008, 05:49 pm GMT +0100
One of the new options in the script is to showcase 5 new and 5 random listings. I've changed the plugin to show only one of each of these. I've also changed it to show the picture associated with the listing. The problem is that those listings that I am adding myself do not have a picture ( screenshots as well as other images are copyrightable and I only want to use pictures with the permission of the site owners and it is also a way to slightly reward the folks who come to me vs the ones I seek out myself.

Archive for SMF v1.00 by N.P. Valid XHTML 1.0 Transitional