I have two normal fields in a view, one optional URL field and one image field. I want that if the optional URL field is empty, the image render as normal, but if the optional URL field contains an URL, then print the mage wrapped in an “A” tag with the optional URL.
I managed to make the part of the Image wrapped in the A tag, but I dont know how to make that part optional.
Any help regarding this?
Install this http://drupal.org/project/views_customfield module(only for D6) and you can add a custom php field in views.
In Fields Section -> Choose Customfield -> and then add Customfield: PHP code
Below is the sample code to get values
first line is like declaration and 2nd & 3rd are to get values from the fields.
replace field_image & field_link with your own fields(see Replacement patterns for your fields)
Using this sample code, change the conditions to your requirement.