Problem setting a variable default when using a ezurl get

Author Message

steve walker

Thursday 09 September 2004 9:11:47 am

Hi there,

I'm trying to use the 'let,default' function documented at http://ez.no/ez_publish/documentation/development/libraries/ez_template/functions/function_list

It has a working example of:

{let var1=42 var2='forty-two'}
{default var1=53}
Variables: {$var1} ({$var2})
{/default}
{/let}

I'm trying to use this with a ezurl get, so I have:

{let carat=ezhttp( 'search_carat', 'get' )}
{default carat=53}
Carat equals: {$carat}
{/default}
{/let}

If the value of carat exists in the url, everything is fine. But if its not there the default statement doesnt work - with no info in the url, i.e. there is nothing to get the value of $carat stays blank?...

Has anyone got an idea why this is happening, or some working code that creates a default value for a variable if there is no 'GET' information in th url?

Thanks, Steve.

http://www.oneworldmarket.co.uk

steve walker

Wednesday 06 October 2004 12:49:04 am

Hi there,

Still trying to work this out...

I have code of:

{let carat=ezhttp('search_carat','get')}
{default carat='0.70-0.89'}

to define the variable carat, and its default if no get variable exists. If I try to print the variable $carat with the above code nothing appears. However, if I get rid of the let statement so I have:

{default carat='0.70-0.89'}

The default variable prints out fine. Its as if the get variable exists in some sense even though there is nothing to print out?

Has anyone got a working example of a get with a default setting?

Thanks, Steve.

http://www.oneworldmarket.co.uk

steve walker

Thursday 07 October 2004 1:36:05 am

Hi,

No replies - but would have thought this is possible, if not a pretty usual requirement.

Has anyone had nay experience of setting a default for a variable populated by a GET if it exists? Ez, can you give some input here?

Thanks, Steve.

http://www.oneworldmarket.co.uk

Paul Borgermans

Thursday 07 October 2004 1:53:07 am

Hi Steve

You may try this:

{let carat=first_set(ezhttp('search_carat', 'get' ),53)}
...
{/let}

I haven't tested this but it .. well .. bears some logic

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

steve walker

Thursday 07 October 2004 3:32:35 am

Tried:

{let cut=(ezhttp('search_cut','get'),53)}

but get error message:

parser error @ design/gia/override/templates/search_stones.tpl:1[8]
Extra characters found, should have been a whitespace or the end of the expression
Characters: '(ezhttp('search_cut','get'),53)'

Any other thoughts?

Regards, Steve.

http://www.oneworldmarket.co.uk

Paul Borgermans

Thursday 07 October 2004 4:43:16 am

Hi Steve,

Didn't you make an error by forgetting the first_set?

This is what works perfectly here (on ezp 3.4.2)

{let cut=first_set(ezhttp('search_cut',get),53)}
cut = {$cut} <br />
{/let}

Also be sure that your syntax is OK in other code fragments (use the template check script if you can)

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

steve walker

Friday 08 October 2004 9:45:47 am

Paul,

I had missed first_set out.

Its working perfectly now :) - cheers!

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 16:27:26
Script start
Timing: Jan 18 2025 16:27:26
Module start 'layout'
Timing: Jan 18 2025 16:27:26
Module start 'content'
Timing: Jan 18 2025 16:27:27
Module end 'content'
Timing: Jan 18 2025 16:27:27
Script end

Main resources:

Total runtime1.2730 sec
Peak memory usage4,096.0000 KB
Database Queries69

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0083 589.2891152.6563
Module start 'layout' 0.00830.0038 741.945339.5078
Module start 'content' 0.01211.2595 781.4531589.5859
Module end 'content' 1.27150.0014 1,371.039116.0938
Script end 1.2730  1,387.1328 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.2845160.0002
Check MTime0.00150.1172160.0001
Mysql Total
Database connection0.00130.104210.0013
Mysqli_queries1.206294.7544690.0175
Looping result0.00060.0452670.0000
Template Total1.226196.320.6130
Template load0.00240.190620.0012
Template processing1.223796.124620.6118
Template load and register function0.00020.018310.0002
states
state_id_array0.00180.139810.0018
state_identifier_array0.00110.085920.0005
Override
Cache load0.00220.1691550.0000
Sytem overhead
Fetch class attribute can translate value0.00070.052120.0003
Fetch class attribute name0.00090.072480.0001
XML
Image XML parsing0.00050.041720.0003
class_abstraction
Instantiating content class attribute0.00000.001090.0000
General
dbfile0.00110.0849170.0001
String conversion0.00000.000840.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
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
15content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
8content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 34
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs