Icon in record view

A place for users and developers of the Xataface to discuss and receive support.

Icon in record view

Postby 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.
cuppieinc
 
Posts: 2
Joined: Sat Nov 12, 2011 9:24 am

Re: Icon in record view

Postby 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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Icon in record view

Postby 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 '<img src="'.$ENV.DATAFACE_SITE_URL.'/images/image.jpg" alt="alternative text"/>';
}
}
}
?>

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

regards,

Patrick
cuppieinc
 
Posts: 2
Joined: Sat Nov 12, 2011 9:24 am

Re: Icon in record view

Postby 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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 13 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved