I can't seem to get this done, i need a loop to check what value another cck field has. Depending on that i want to do some actions and return a var, here is the code:

if( $node->field_product_leverancier[0]['value'] == "http://clk.tradedoubler.com/click?a=1675&p=678&g=172976&epi=%epi%&url=%url%" ):
  $veld = $node->field_product_leverancier[0]['value'];
  $epi = strtolower( str_replace(" ", "-", $title) );
  $bestel_epi = str_replace("%epi%", $epi, $veld);
  $bestel =  str_replace("%url%", $node->field_bestel_adres[0]['value'], $bestel_epi );
elseif( $node->field_product_leverancier[0]['value'] == "http://ds1.nl/c/?wi=457&si=%si%&li=%li%&dl=%url%&ws=%ws%" ): 
  $veld = $node->field_product_leverancier[0]['value'];
  $ws = strtolower( str_replace(" ", "-", $title) );
  $bestel_ws = str_replace("%ws%", $ws."-tijdschrift", $veld);
  $bestel_si = str_replace("%si%", $node->field_kliks_merchant[0]['value'], $bestel_ws); 
  $bestel_li = str_replace("%li%", $node->field_kliks_merchant_li[0]['value'], $bestel_si); 
  $bestel =  str_replace("%url%", $node->field_bestel_adres[0]['value'] , $bestel_li );
else:
  $bestel = "ERROR";
endif;
$node_field[0]['value'] = $bestel;

Is a if even possible in computed fields? Because when i only return the $node_field[0]['value'] = $node->field_product_leverancier[0]['value'] it does return the url i have set for the product_leverancier field.

Comments

Michsk’s picture

Version: 5.x-1.2 » 6.x-1.0-beta3

Wrong version.

Michsk’s picture

mmm loop must be possible because he does echo error, so it does do the check...

Michsk’s picture

Check seems to work the & where converted to &. Because of that it did not pass the if. So the if check works but the str_replace does not seem to work...

Michsk’s picture

Everything works.

mmjvb’s picture

Status: Active » Closed (outdated)