View Single Post
  #2  
Old 08-25-2003, 09:49 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

Okay - there is not a standard smarty or xcart way of doing this but....

first:

create a new modifier file: modifier.file_exist.php and save it into your smarty plugins folder.

Code:
<?php /* * Smarty plugin * ------------------------------------------------------------- * Type: modifier * Name: file_exists * Purpose: checks if a file exist * ------------------------------------------------------------- */ function smarty_modifier_file_exists($params, &$smarty) { extract($params); if (empty($file)) { $smarty->trigger_error("assign: missing 'file' parameter"); return; } return file_exists($file); } ?>

Then in the template where you wish for the file check to be used:

{assign var="file" value="the_image_check_for.gif"}
{if $file|file_exists}
[img]{$file}[/img]
{else}
Show another image
{/if}

That'll do it
__________________
ex x-cart guru
Reply With Quote