How to Customize the View Tab

This document explains how you can customize the view tab.

Xataface 0.7 introduces marked improvements in its view tab template.  Some of these improvements include:

  • A logo - Records with Image or blob fields can have the image displayed as a logo in the upper right of the record details.
  • Field grouping - Fields are displayed in groups, respecting the group attribute in the fields.ini file.
  • Description & Status message - If the record has a last modified date, this will be displayed at the top with a short description of the record.
  • Relationships - The first few records of each of the record's relationships are displayed.
  • Sections - You can add your own custom sections to the view tab using the delegate class.

An example of the new view tab template:


new-view-tab.gif

Things to notice about this template:

  1. The image in the upper left is treated as a logo.  Xataface uses a few heuristics to find out if the record has a logo.  Read further in this document for information on how to configure this in Xataface.
  2. The Profile Pages and News sections are actually relationships.  These sections show the top 5 records in the relationship.  If you click the see all link in the upper right of either section, it will go to the rest of the related records for that relationship.
  3. The Wholesaler information and company rep submits profile page are custom sections that have been added via the delegate class.  The Details Section actually shows the field information stored in the record.
  4. Users can minimize any of these sections by clicking the top bar.
  5. These sections can all be reordered in the fields.ini file or the delegate class.

Configuring the Logo Field

By default, any images that are stored in blob or container fields of the current record are displayed in the upper left of the view tab.  If no such logo is found, a default image of a 'question mark' will be displayed in its place to indicate that no image was found.   If you are not happy with the default logo chosen, or you want to change some aspects of the logo, Xataface provides a few configuration parameters in the fields.ini file to help you with this.

Choosing which logo to display

If a table has more than one image stored per record, Xataface will choose the first image by default.  You can use the 'logo' attribute in the fields.ini file to specify a different field to be used as the logo.

e.g.  fields.ini file for table.

[big_image]
     widget:description="Please select a large image for this record"

[small_image]
     widget:description="Please select a small image for this record"
     logo=1 ;; Specify that we want the small_image field to be displayed as the record logo in the view tab.

In the above example, the big_image would have been displayed by default, but, because we have specified the 'logo' attribute on the small_image field, it will be used instead.


Disabling the Logo field application wide

Perhaps you don't like having the logo field there at all.  The hide_record_view_logo preference setting can be used to hide the logo for all records in the application.

e.g. conf.ini file.

[_prefs]
     hide_record_view_logo=1

Using a non-container field as the logo

Perhaps you are allowing users to specify the logo as a URL into a text field.  Since the field is a text field, Xataface won't automatically understand that you indend it to be used as a logo.  You might try to turn it into a logo using the logo attribute in the fields.ini file, but you'll be disappointed when your application displays the URL for the image rather than the image itself.  In this case, you must also define a %fieldname%__toHtml() method in the delegate class to specify the HTML that should be used to render the field.

e.g. Suppose we have a field named headshot_url, a text field where the user enter a URL to their headshot.

fields.ini

[headshot_url]
     widget:type=text
     widget:description="Please enter the URL for your headshot here.  e.g. http://www.mydomain.com/headshot.jpg"
     logo=1

and in the delegate class (e.g. tables/people/people.php)

...
function headshot_url__htmlValue(&$record){
     return '<img src="'.$record->val('headshot_url').'" alt="headshot"/>';
}
...

Now the Image specified in the url will be displayed as the logo in the view tab for each record.


Powered by Dataface
(c) 2005-2007 All rights reserved