Caution: This documentation is for eZ Publish legacy, from version 3.x to 6.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

first_set

Summary

Returns the first parameter that is set (or FALSE).

Usage

first_set( value1 [, value2 [, ... ] ] )

Parameters

NameTypeDescriptionRequired
value1 any A variable/value that should be evaluated. Yes.
value2 any Another variable/value that should be evaluated. No.

Returns

The first value that is set or FALSE.

Description

This operator evaluates all parameters until one of them is found to be set. The parameter that is found to be set will be returned. If none of the parameters are set, the operator will return FALSE.

Examples

Example 1

{if first_set( $a, $b, $c )}
    The truth is out there.
{else}
    The day the earth stood still.
{/if}

As long as $a, $b and $c are undeclared/unset, the following output will be produced: "The day the earth stood still".

Example 2

{first_set( $a, 256, $b )}

As long as $a is undeclared/unset, the following output will be produced: "256".

Balazs Halasy (05/02/2004 10:40 am)

Balazs Halasy (04/05/2005 2:07 pm)


Comments

  • This code will give you unexpected results

    This code:
    {def $myvar = first_set($myobject.contentobject.data_map.my_integer_var.data_int, 0)}
    MYVAR = {$idanag}; {$myobject.contentobject.data_map.my_integer_var.data_int}
    

    will display
    MYVAR = ; 0

    instead of
    MYVAR = 0; 0
    so, first_set handles 0s as "unset". this either needs to be documented or marked as a bug.
    • Re: This code will give you unexpected results

      I guess moste people will see what this person did wrong here.
      1.$idanag is not defined as far as I can see. Debug is your friend.
      2. a value of 0 = is_set, its not true but it's set. But the ouput would be the same anyway.