This topic is locked

Custom List Field

3/8/2011 11:54:55 AM
PHPRunner General questions
M
mrphp author

Hello,
I have a view with the following custom field:
if ($data["bid"]) $color="blue";else $color="333333";$value="<font color='$color'>$value</font>";
Thus if there is a file attached to "bid" a particular item in the View is blue. What I would like to do is modify the IF statement to include an OR condition but I'm not able to get it to work. There is another field called "drawing" and I would like the List Item to be blue if either or both of the fields "bid" and "drawing" have an attachment. How is this done? I've tried "elseif" but my syntax must be incorrect.
Here is what doesn't work:

if ($data["bid"])

$color="blue";

elseif ($data["drawings"])

$color="blue";

else

$color="333333";

$value="<font color='$color'>$value</font>";


What have I done wrong?
Thanks.

Sergey Kornilov admin 3/9/2011

Your code looks correct but here is the shorter version that you should try.



if ($data["bid"] || $data["drawings"])

$color="blue";

else

$color="#333333";

$value="<font color='" . $color . "'>" . $value . "</font>";


Also make sure field names are correct (drawing vs drawings).