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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:12:24
Script start
Timing: Jan 18 2025 19:12:24
Module start 'layout'
Timing: Jan 18 2025 19:12:24
Module start 'content'
Timing: Jan 18 2025 19:12:24
Module end 'content'
Timing: Jan 18 2025 19:12:24
Script end

Main resources:

Total runtime0.7511 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 589.2891152.6563
Module start 'layout' 0.00580.0042 741.945339.5078
Module start 'content' 0.01000.7397 781.4531496.5078
Module end 'content' 0.74970.0014 1,277.96098.1094
Script end 0.7511  1,286.0703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4645160.0002
Check MTime0.00150.2024160.0001
Mysql Total
Database connection0.00100.135510.0010
Mysqli_queries0.707094.1254570.0124
Looping result0.00060.0739550.0000
Template Total0.718295.620.3591
Template load0.00210.276220.0010
Template processing0.716195.342420.3581
Template load and register function0.00040.055910.0004
states
state_id_array0.00090.115010.0009
state_identifier_array0.00280.369820.0014
Override
Cache load0.00170.2242170.0001
Sytem overhead
Fetch class attribute can translate value0.00060.081420.0003
Fetch class attribute name0.00100.137730.0003
XML
Image XML parsing0.00030.036120.0001
class_abstraction
Instantiating content class attribute0.00000.001230.0000
General
dbfile0.00070.0916100.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs