Forums / Setup & design / How to check if price equals 0

How to check if price equals 0

Author Message

Espen R

Thursday 15 March 2007 6:24:40 am

Hi!

I'm trying to get a price to show in a template only if the value is more than 0.

I have tried the following code with no luck. The ezprice attribute is called "pris".

{if $node.object.data_map.pris.content.data_float|not(0)}
    Pris: {attribute_view_gui attribute=$node.object.data_map.pris}	
{/if}

This code shows the price even if it is 0. What stupid mistake am I doing here? :)

Sébastien Antoniotti

Thursday 15 March 2007 7:05:40 am

Hi,

You can try this :

{if gt($node.object.data_map.pris.content.data_float,0)}

eZ Publish Freelance
web : http://www.webaxis.fr

Espen R

Thursday 15 March 2007 7:24:52 am

Thanks for trying, but it doesn't work. It doesn't output anything no matter what the value is.

I have checked that the ezprice object attribute is "data_float" and that is has a value using

{$node.object.data_map.pris|attribute(show)}

but no..

eZ version is 3.6.11 btw.

Sébastien Antoniotti

Thursday 15 March 2007 7:34:50 am

and with

 

{if gt($node.object.data_map.pris,0)}
 

?

eZ Publish Freelance
web : http://www.webaxis.fr

Espen R

Thursday 15 March 2007 8:01:01 am

Sorry but it doesn't work either. It always shows the price. :(

Claudia Kosny

Thursday 15 March 2007 8:18:10 am

Hi Espen

If you check http://ez.no/doc/ez_publish/technical_manual/3_8/reference/datatypes/price you can see that the content of a price attribute is an ezprice object. The documentation about this object here http://ez.no/doc/ez_publish/technical_manual/3_8/reference/objects/ezprice tells you what attributes this object has.

So try

{if $node.object.data_map.pris.content.price|gt(0)}
   Pris: {attribute_view_gui attribute=$node.object.data_map.pris}     
{/if}

Claudia

EDIT:
I replaced ...price|not(0)} with ...price|gt(0).
/EDIT

Espen R

Friday 16 March 2007 5:16:32 am

Thanks Claudia!

That worked like a charm. Thought I had tried that but I apparently hadn't.