Forums / Setup & design / Section/Else syntax to check if external file exists

Section/Else syntax to check if external file exists

Author Message

steve walker

Tuesday 26 April 2005 10:17:11 am

Hi there,

I'm trying to create an if/then statement that looks to see if a file outside of Ez exists and then to execute code dependent on this condition. Something along the lines of:

IF '{$node.name}.jpg' DOES NOT EXIST
	<a href="/certificates/default.jpg">view certificate...</a>
ELSE
	<a href="/certificates/{$node.name}.jpg">view certificate...</a>

...but I dont know how I ask Ez to see if a file exists?

Could anyone give me a pointer here?

Thanks, Steve.

http://www.oneworldmarket.co.uk

Paul Forsyth

Tuesday 26 April 2005 11:46:33 am

You might need to drop down to php to perform the file check. A small ezoperator might be the easiest approach, allowing you to:

$myfile = "/here/pic.jpg"

{section show=$myfile|file_exists}
Do something
{/section}

You might be lucky and be able to add the function 'file_exists' to template.ini. See the [PHP] group for more details in that ini file.

paul

steve walker

Wednesday 27 April 2005 2:12:22 am

Excellent - thanks Paul.

Steve.

http://www.oneworldmarket.co.uk