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.