Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
Michsk CreditAttribution: Michsk commentedWrong version.
Comment #2
Michsk CreditAttribution: Michsk commentedmmm loop must be possible because he does echo
error
, so it does do the check...Comment #3
Michsk CreditAttribution: Michsk commentedCheck 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...Comment #4
Michsk CreditAttribution: Michsk commentedEverything works.
Comment #5
mmjvb CreditAttribution: mmjvb as a volunteer commented