I am wishing to use the Code Pack beforerender field in order to change the output on an image field. I have a list, with 9 results and I would like to display a default image if there is no image in a field called 'image', plus wrap the that field in a div. 7 of these results have an image uploaded, 2 do not.
So I tried the following code - which is a guess because of the lack of documentation:
if ( $fields['image']->value ) {
print $fields['image']->form;
} else {
print ('<img src="/default.jpg" alt="Hello" />');
}
Which returns 2 instances of this code:
<img src="/default.jpg" alt="Hello" />
at the top of the list.
Well, that's wrong, but I know that the BeforeRender field is working at some level. What I am unable to do is affect any of the fields in the list with any variation of my code above. There does not seem to be any tutorial explaining the basics of the Code Pack field in terms of how to place it, where to place it and what to do with the other fields it is affecting.
So could somebody please help!