Icon in record view

Archived from the Xataface Users forum.

cuppieinc — Sat Nov 12, 2011 9:33 am

Hi, I would like to know if and how it is possible to have an icon displayed in the list view within a record. I have setup document uploads to the file systems and created two icons in the images folder within the site for document available and no document available. What I would like is that in the list view not the full path to the uploaded document is displayed but just an icon if a document is available or not. I have been playing with the function fieldname__renderCell but i can’t figure it out. I can return text based upon the fact if a document is uploaded or not but I can’t get the record to display an Icon.

any help would be great,

Thnx,
Patrick.


shannah — Sat Nov 12, 2011 11:27 am

Use the fieldname__renderCell() delegate class method to override what is displayed in the list view cell for one of the columns. This is described on this page.

http://xataface.com/documentation/how-to/list_tab


cuppieinc — Sun Nov 13, 2011 3:10 pm

Thnx for the link, I got it working. The problem was that I wanted to use $ENV.DATAFACE_SITE_URL for displaying the image in list view but put it in as plain text within the php file. I got it working using the following :

<?
class tables_tablename {

function fieldname__renderCell( &$record ){
if ($record->val(‘Fieldname’) != ‘’){

return ‘alternative text’;
}
}
}
?>

this displays the image.jpg in list view when the upload field in the record is not empty.

regards,

Patrick


shannah — Sun Nov 13, 2011 6:32 pm

Thanks for posting your solution. One tweak:

Code: Select all
return '<img src="'.$ENV.DATAFACE_SITE_URL.'/images/image.jpg" alt="alternative text"/>';

should be

Code: Select all
return '<img src="'.DATAFACE_SITE_URL.'/images/image.jpg" alt="alternative text"/>';

$ENV.DATAFACE_SITE_URL is a variable in smarty templates only. In PHP you use the DATAFACE_SITE_URL constant directly.

-Steve