|
|
|
News id
|
34
|
Headline
|
Xataface: Setting a logo for a xataface record
|
Content
|
When you go into the details view of a record, in addition to the all the different values in the database about the record, you can also specify a logo for that record and this logo will appear in the top left corner of the record.<br /><br />You should first refer to this <a href="http://framework.weblite.ca/documentation/how-to/how-to-handle-file-uploads">document</a> on how to actually store images/file in xataface.<br /><br />I used method two because I always find it much easier to manage when the files exist physically and not just as bytes in the database. So let's assume that the picture field in the database is what is storing the file name in the database, and you have a directory called picture in your delegate class.<br /><br />The next step is to go into your delegate class that represents this record and include this function:<br /><br /><br /><blockquote><br /><br />function field__friend_picture(&$record){<br /> return '<img src="'.$record->display('picture').'"></img>'; <br /> } <br /><br /></blockquote><br /><br />What this does is define a custom field called friend_picture which will basically return the image. By using $record->display() we are returning the whole address of the picture. Xataface is smart enough to figure out how to return the address.<br /><br />This is opposed to using $record->val('picture') which would return the raw value of the field in the database which would just be the filename. <br /><br />And then final step is to go into the fields.ini file of this delegate class and include this:<br /><br /><blockquote><br />[friend_picture]<br />logo = 1<br /></blockquote><br /><br />This causes xataface to recognize this was a logo field for the record and then display the picture in the top left hand corner of the detail view of the record.<br /><br />And volia!<br /><br />Some things to note is that trying to include the logo = 1 as attribute for the field that holds the filename that's seem to work. For example, say in the fields.ini file you have:<br /><br /><blockquote><br />[picture]<br />logo = 1<br /></blockquote><br /><br />This would place this field to the top left hand corner, but it would just say "View Field Content In New Window ()" in the top left hand corner. You have to make a custom field. <br /><br />Also, you can specify exactly records of which table should display logos by including this line of code in the ApplicationDelegate class' getPreferences() function:<br /><br /><blockquote><br />//this is needed to determine which table records will have a logo on them<br /> if ( !in_array($query['-table'], array('companies', 'dealers','news', 'strategies', 'offerings') ) ){<br /> $prefs['hide_record_view_logo'] = 1;<br /> }<br /></blockquote><br /><br />What this basically did was check whether the current table viewing this record was either companies, dealer, etc. And if it wasn't, it would turn the hide_record_view_logo preference. So a modified line of code could be like this:<br /><br /><blockquote><br />if ( !in_array($query['-table'], array('companies', 'dealers','news', 'strategies, 'offerings') ) ){<br /> $prefs['hide_record_view_logo'] = 1;<br /> }<br /></blockquote>
|
Image
|
(Empty)
|
Date posted
|
Thu Jul 31 11:40:00 2008
|
Posted by
|
noreply@blogger.com (Fong Chun Chan)
|
Status
|
Approved
|
Categories
|
Blog
|
Source id
|
Fong's Blog
|
Source url
|
http://fongxataface.blogspot.com/2008/07/xataface-setting-logo-for-xataface.html
|
|
|