13, May 2008

If Exist in a CMS Environment? - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  Miscellaneous Languages
Topic: If Exist in a CMS Environment?
« previous next »
Pages: [1] Print

Author Topic: If Exist in a CMS Environment?  (Read 112 times)
I am a fanatic. So?
*****
Gender: Female
Posts: 584
3633 credits
Members referred : 2



« on: May 08, 2008, 07:04:10 PM »

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.

www.yourmessageconsultant.com Visit through proxy, providing online content and printed marketing materials.
www.helpforwebbeginners.com Visit through proxy, Tutorials and how to's for new  webmasters.
www.CraftyTips.com Visit through proxy, a unique Arts & Crafts Directory
www.nocans.com Visit through proxy - Pet Food Recipe Site
www.petsiteguides.com Visit through proxy - A New Pet Directory

Last blog : Privacy Policy for Blog About Crafts
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7824
39879 credits
Members referred : 3



« Reply #1 on: May 08, 2008, 11:48:25 PM »

This is easy to accomplished. Use a code like this :

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

Trial and Error my two best teachers Cool
Promote your blog for free.... Visit through proxy

Last blog : Keep it Legal - Tims guide to legal notices
I am a fanatic. So?
*****
Gender: Female
Posts: 584
3633 credits
Members referred : 2



« Reply #2 on: May 09, 2008, 01:36:50 AM »

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/ Visit through proxy{$new_listing.id}.jpg) ){
 <img src="http://www.petsiteguides.com/site-thumbs/ Visit through proxy{$new_listing.id}.jpg" alt="{$new_listing.title|replace:"&":"and"}" />
}

[/blockquote]

$new_listing.id holds the record number

Where did I go wrong?

www.yourmessageconsultant.com Visit through proxy, providing online content and printed marketing materials.
www.helpforwebbeginners.com Visit through proxy, Tutorials and how to's for new  webmasters.
www.CraftyTips.com Visit through proxy, a unique Arts & Crafts Directory
www.nocans.com Visit through proxy - Pet Food Recipe Site
www.petsiteguides.com Visit through proxy - A New Pet Directory

Last blog : Privacy Policy for Blog About Crafts
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7824
39879 credits
Members referred : 3



« Reply #3 on: May 09, 2008, 03:09:08 PM »

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

Trial and Error my two best teachers Cool
Promote your blog for free.... Visit through proxy

Last blog : Keep it Legal - Tims guide to legal notices
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7731
Tags : if exist web programming Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  Miscellaneous Languages
Topic: If Exist in a CMS Environment?
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 13, 2008, 07:30:59 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 34.931
Total Topics: 7.262
Total Members: 3.482
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: ondho

16 Guests, 4 Users online :

12 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.