Forums / Setup & design / Problem setting a variable default when using a ezurl get

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

eZ debug

Timing: Jan 18 2025 11:05:41
Script start
Timing: Jan 18 2025 11:05:41
Module start 'content'
Timing: Jan 18 2025 11:05:42
Module end 'content'
Timing: Jan 18 2025 11:05:42
Script end

Main resources:

Total runtime0.7181 sec
Peak memory usage4,096.0000 KB
Database Queries206

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 589.3984180.7969
Module start 'content' 0.00560.5874 770.1953594.6953
Module end 'content' 0.59310.1250 1,364.8906341.0234
Script end 0.7180  1,705.9141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.5780210.0002
Check MTime0.00150.2107210.0001
Mysql Total
Database connection0.00070.095810.0007
Mysqli_queries0.637288.73152060.0031
Looping result0.00190.26812040.0000
Template Total0.693096.520.3465
Template load0.00210.295220.0011
Template processing0.690996.206420.3454
Template load and register function0.00020.027610.0002
states
state_id_array0.00070.102510.0007
state_identifier_array0.00070.103620.0004
Override
Cache load0.00170.2436550.0000
Sytem overhead
Fetch class attribute can translate value0.00110.156230.0004
Fetch class attribute name0.00090.126680.0001
XML
Image XML parsing0.00100.136330.0003
class_abstraction
Instantiating content class attribute0.00000.002390.0000
General
dbfile0.00350.4868280.0001
String conversion0.00000.000930.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 34
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs