<?xml version="1.0"?>
<record><news id="news?news_id=72">
	<news_id>72</news_id>
	<headline>Adding some text when no block/slot exists</headline>
	<description></description>
	<content>Sometimes you need to add some text to a certain template, but Xataface doesn&apos;t have the specific block or slot to use.  For example, say you wanted to include some text underneath the password field in the login page for Xataface.  You can&apos;t do this with blocks or slots since nothing exists underneath that field.  You can however do a workaround by using javascript and the DOM concept.  br /br /For example:br /br /blockquotebr /function block__after_login_form(){br /lt;script language=quot;javascriptquot;gt;lt;!--br /var div = document.createElement(#39;div#39;);br /div.className = &apos;formHelp&apos;;br /var text = document.createTextNode(#39;Please enter the correct password#39;);br /div.appendChild(text);br /br /document.getElementById(#39;Login-Password#39;).appendChild(div);br ///--gt;lt;/scriptgt;br /}br //blockquotebr /br /First thing to notice is we are using the block__after_login_form() which simply a block on that template.  We are using it to include our javascript of interest.  We could have actually used any block. br /br /blockquotevar div = document.createElement(#39;div#39;);/blockquotebr /br /The first thing we do is create a div element.br /br /blockquotediv.className = &apos;formHelp&apos;;/blockquotebr /br /Here are just giving it the css class name of formHelp which gives it a nice styling feel.  This is the same style used for widget:description values.br /br /blockquotevar text = document.createTextNode(#39;Please enter the correct password#39;);/blockquotebr /br /And then we create a textnode which contains the text of interest.br /br /blockquotediv.appendChild(text);/blockquotebr /br /With out div element, we are appending the text node we just created to it.br /br /blockquotedocument.getElementById(#39;Login-Password#39;).appendChild(div);/blockquotebr /br /And finally we add our div element to our element of interest which happens to have the id of &quot;Login-Password&quot;  This id has been assigned by Xataface itself.br /br /And if everything works out fine, then you should see the text appear below the password field!br /br /You can find more information about how to manipulate DOM structure using javascript a href=&quot;http://www.howtocreate.co.uk/tutorials/javascript/domstructure&quot;here/a.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Wed Nov 12 07:01:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/11/adding-some-text-when-no-blockslot.html</source_url>
</news>
<news id="news?news_id=71">
	<news_id>71</news_id>
	<headline>Testing Xataface on IE6 when you have Vista</headline>
	<description></description>
	<content>So I ran into a pretty annoying problem the other day.  I had to test a Xataface application on IE6 with Vista as my OS.  Which basically meant I had IE7 preinstalled, and I couldn&apos;t install IE6.  Ughh...annoying.  I don&apos;t understand why people still use IE6, but whatever.br /br /The best way to actually shove this is to install a virtual machine with the OS set to XP and then you can use IE6 on it.  To do this follow this a href=&quot;http://www.raizlabs.com/blog/?p=221&quot;tutorial/a.  br /br /One thing you need to note is that Virtual PC 2004 does NOT work on Vista.  So you actually have to use Virtual PC (VPC) 2007 .  This can be found a href=&quot;http://www.microsoft.com/downloads/details.aspx?FamilyId=04D26402-3199-48A3-AFA2-2DC0B40A73B6displaylang=en&quot;here/a.  The &quot;Internet Explorer 6 Testing VPC Image&quot; is still the same.br /br /Another annoying thing is that VPC 2007 is NOT fully supported with Vista Home edition (UGHHH...why are things to complicated!).  And you&apos;ll be faced with all these messages not non-compatibility.  But you are just limited from some features which I didn&apos;t bother looking directly into.  But if you just want to test Xataface sites on it, then just ignore the messages and install it.br /br /After you have loaded the VPC image, then the next step is to actually setup internet connection from inside the VPC.  If you are using a LAN connection, then do this:br /br /olbr /liEdit/libr /liSettings/libr /liNetworking /libr /liAdaptor 1: NAT/libr //olbr /br /Try to connect now, and if you have a firewall on then you will be prompted to allow the VPC to pass it.  After you &quot;unblock&quot; it, then everything should work!br /br /If you are using wireless, then use this a href=&quot;http://claytonj.wordpress.com/2007/02/02/connect-virtual-pc-to-internet/&quot;tutorial/a.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Sun Nov 16 07:42:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/11/testing-xataface-on-ie6-when-you-have.html</source_url>
</news>
<news id="news?news_id=70">
	<news_id>70</news_id>
	<headline>SVN committing</headline>
	<description></description>
	<content>This isn&apos;t exactly a Xataface related issue, but I found myself continually forgetting about this that I thought it would be good to blog about this so I can remember.  When I have ssh&apos;ed onto the server and I need to do a svn commit, I get an error message about not having an editor to input my svn commit message.  The following piece of code fixes this:br /br /blockquotebr /export EDITOR=vibr //blockquotebr /br /Where vi is the editor program we are using.  If you have something else installed on your server (and hopefully you do because vi really blows), then you can just use that.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Sat Nov 22 13:01:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/11/svn-committing.html</source_url>
</news>
<news id="news?news_id=33">
	<news_id>33</news_id>
	<headline>Displaying Xataface record values</headline>
	<description></description>
	<content>Taking a look at the Xataface Record API presents you with several techniques to display the values of the record.  At the lowest level, there is a function called val and can be called like this (assuming $rec is a Xataface record)&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;$rec-&gt;val(&apos;fieldname&apos;)&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;What this does is it displays the raw value of field.  As in exactly what is stored in the database.  &lt;br /&gt;&lt;br /&gt;But what happens if the value is say a foreign key to another table say like a number of a company.  We don&apos;t really want to display just the number, but rather the company name of the id.  If a valuelist has been setup for this company_id in a valuelist.ini file, then you can easily display the field you really want by simply using the &quot;display&quot; function.  &lt;br /&gt;&lt;br /&gt;So say for example, in your application delegate&apos;s valuelists.ini file you have this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;[companies]&lt;br /&gt;__sql__=&quot;select company_id,company_name from companies order by company_name&quot;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;So you are basically telling Xataface to use the company_name as a replacement for the company_id.  Since this is the application&apos;s delegate, this valuelist is accessible by any table and can be overwritten the own table&apos;s valuelist.  In any case, if in your other table you just call:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;$rec-&gt;display(&apos;company_id&apos;)&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Xataface will be smart enough to use the company_name in replacement for the company_id.  This display function is also useful for database field types datetime, time, or date.  If you were simply use the &quot;val&quot; function it would return the date as an array with keys &quot;year&quot;, &quot;month&quot;, &quot;seconds&quot;, etc.  And you would be left with having to piece together the information yourself.  But by using the display() function you can quickly circumvent this problem.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Sat Aug  2 03:41:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/08/displaying-xataface-record-values.html</source_url>
</news>
<news id="news?news_id=34">
	<news_id>34</news_id>
	<headline>Xataface: Setting a logo for a xataface record</headline>
	<description></description>
	<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.&lt;br /&gt;&lt;br /&gt;You should first refer to this &lt;a href=&quot;http://framework.weblite.ca/documentation/how-to/how-to-handle-file-uploads&quot;&gt;document&lt;/a&gt; on how to actually store images/file in xataface.&lt;br /&gt;&lt;br /&gt;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&apos;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.&lt;br /&gt;&lt;br /&gt;The next step is to go into your delegate class that represents this record and include this function:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;br /&gt;function field__friend_picture(&amp;$record){&lt;br /&gt;  return &apos;&amp;lt;img src=&quot;&apos;.$record-&gt;display(&apos;picture&apos;).&apos;&quot;&amp;gt;&amp;lt;/img&amp;gt;&apos;;   &lt;br /&gt; } &lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;What this does is define a custom field called friend_picture which will basically return the image.  By using $record-&gt;display() we are returning the whole address of the picture.  Xataface is smart enough to figure out how to return the address.&lt;br /&gt;&lt;br /&gt;This is opposed to using $record-&gt;val(&apos;picture&apos;) which would return the raw value of the field in the database which would just be the filename. &lt;br /&gt;&lt;br /&gt;And then final step is to go into the fields.ini file of this delegate class and include this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;[friend_picture]&lt;br /&gt;logo = 1&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;And volia!&lt;br /&gt;&lt;br /&gt;Some things to note is that trying to include the logo = 1 as attribute for the field that holds the filename that&apos;s seem to work.  For example, say in the fields.ini file you have:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;[picture]&lt;br /&gt;logo = 1&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;This would place this field to the top left hand corner, but it would just say &quot;View Field Content In New Window ()&quot; in the top left hand corner.  You have to make a custom field.  &lt;br /&gt;&lt;br /&gt;Also, you can specify exactly records of which table should display logos by including this line of code in the ApplicationDelegate class&apos; getPreferences() function:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;//this is needed to determine which table records will have a logo on them&lt;br /&gt;  if ( !in_array($query[&apos;-table&apos;], array(&apos;companies&apos;, &apos;dealers&apos;,&apos;news&apos;, &apos;strategies&apos;, &apos;offerings&apos;) ) ){&lt;br /&gt;   $prefs[&apos;hide_record_view_logo&apos;] = 1;&lt;br /&gt;  }&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;What this basically did was check whether the current table viewing this record was either companies, dealer, etc. And if it wasn&apos;t, it would turn the hide_record_view_logo preference.  So a modified line of code could be like this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;if ( !in_array($query[&apos;-table&apos;], array(&apos;companies&apos;, &apos;dealers&apos;,&apos;news&apos;, &apos;strategies, &apos;offerings&apos;) ) ){&lt;br /&gt;            $prefs[&apos;hide_record_view_logo&apos;] = 1;&lt;br /&gt;        }&lt;br /&gt;&lt;/blockquote&gt;</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Thu Jul 31 00:40:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/07/xataface-setting-logo-for-xataface.html</source_url>
</news>
<news id="news?news_id=39">
	<news_id>39</news_id>
	<headline>Smarty Tags</headline>
	<description></description>
	<content>So Xataface employs smarty templates throughout its application to apply its styles and stuff.  I am not 100% sure how it works, but there are list of ENV variables which are available to be used throughout any template file in xataface.   These ENV variables can be found at this &lt;a href=&quot;http://lamp.weblite.ca/dataface-0.6/docs/index.php?-table=Classes&amp;-action=browse&amp;ClassID=%3D41&quot;&gt;link&lt;/a&gt;.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Thu Jun  5 04:13:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/06/smarty-tags.html</source_url>
</news>
<news id="news?news_id=42">
	<news_id>42</news_id>
	<headline>The debug option</headline>
	<description></description>
	<content>You have the option of turning on debug = 1 in the conf.ini file in the application folder of a Xataface application.  What this will do is basically display all the possible blocks you can insert code/templates into. &lt;br /&gt;&lt;br /&gt;Slots will not be displayed in the page, but rather they will be present in the html code in comments.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Tue Jun  3 14:36:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/06/debug-option.html</source_url>
</news>
<news id="news?news_id=47">
	<news_id>47</news_id>
	<headline>Xataface - How to unset tabs in the table view</headline>
	<description></description>
	<content>Inside of a delegate class&apos; fields.ini file, you can specify the notion of &quot;tabs&quot; and actually put separate fields into their tabs.  &lt;br /&gt;&lt;br /&gt;Sometimes you don&apos;t want a tab to appear in the view of a record.  You can set the permissions of this like this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;br /&gt;function __tabs__(&amp;$record){&lt;br /&gt;    $user =&amp; getUser();&lt;br /&gt;        &lt;br /&gt;    $t =&amp; $record-&gt;_table;&lt;br /&gt;    $tabs = $t-&gt;_tabs;&lt;br /&gt;    if ( $record and !isAdmin() ){&lt;br /&gt;        &lt;br /&gt;        if ( !$record-&gt;val(&apos;people_approval_status&apos;) )&lt;br /&gt;            unset($tabs[&apos;__people__&apos;]);&lt;br /&gt;        if ( !$record-&gt;val(&apos;researcher_approval_status&apos;) )&lt;br /&gt;            unset($tabs[&apos;__gcms__&apos;]);&lt;br /&gt;    }&lt;br /&gt;    return $tabs;&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Here we call the __tabs__ function to actually process the tabs before they are run.  And then we unset the tabs that we don&apos;t want the user to see.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Wed Apr 23 00:29:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/04/xataface.html</source_url>
</news>
<news id="news?news_id=67">
	<news_id>67</news_id>
	<headline>Getting related records</headline>
	<description></description>
	<content>One thing you&apos;ll want to do is to grab related records in Xataface.  Say for example, you have an abstract record that belongs to a conference.  In the relationships.ini file of your abstract table, you would include something like this:br /br /blockquotebr /[Conference]br /conference.ConferenceID=&quot;$AbstractConferenceID&quot;br //blockquotebr /br /Where the conference is the name of the conference table, ConferenceID is the name of the index of that table, and $AbstractConferenceID is the foreign ID in your abstract record that corresponds to the the particular record in the conference table.  Note the name of the relationship is &quot;Conference.&quot;br /br /In Xataface, if you have an abstract record you can quickly retrieve the related conference by simply doing this:br /br /blockquotebr /$conference = $record-getRelatedRecord(&apos;Conference&apos;)br //blockquotebr /br /This will retrieve the conference as a xataface_related_record object.  It is important to realize that this is not the same thing as a xataface_record.  If you want to convert this related_record object into a xataface_record object you can use the toRecord() function:br /br /blockquote$conference = $record-getRelatedRecord(&apos;Conference&apos;)-toRecord();/blockquotebr /br /This is a powerful technique that can save a lot of time.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Tue Dec 16 04:38:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/12/getting-related-records.html</source_url>
</news>
<news id="news?news_id=68">
	<news_id>68</news_id>
	<headline>Xataface svn repository</headline>
	<description></description>
	<content>One good thing you should do if you are planning to develop an application with Xataface is to actually checkout the svn repository of Xataface.  The most recent code for Xataface which includes bug fixes and features will be added to this repository.  I used tortoiseSVN as my svn client, and to checkout you simply use this address:br /br /blockquotehttp://weblite.ca/svn/dataface/core/trunk/blockquote</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Fri Nov 28 13:43:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/11/xataface-svn-repository.html</source_url>
</news>
<news id="news?news_id=69">
	<news_id>69</news_id>
	<headline>Keeping your database up to date throughout development</headline>
	<description></description>
	<content>A major development issue in any computer project that requires a database is keeping your database structure keep to date with the different versions of the code.  Keep database up to date is always a difficult because you cannot simply put it under version (thou technically you can because you can create an sql statement that represents the entire database).  But Xataface provides an interesting way to handle this through the use of an installer.php class in the conf folder.  br /br /The idea behind this is your application will be associated with a version number which you specify in the database.  And then Xataface will run the installer.php file which checks which version is in the database, and then it will call a bunch of functions that update the database table.  The functions are named after the version number they should be applied to.  So for example:br /br /blockquotebr /lt;?phpbr /class conf_Installer {br /function update_582(){br /$sql[] = #39;ALTER TABLE `webpage_sites` ADD `dynamic` TINYINT(1) AFTER `require_approval`#39;;br /$sql[] = #39;ALTER TABLE `webpage_sites` ADD `irrelevant_get_params` TEXT NULL AFTER `aliases` , ADD `relevant_get_params` TEXT NULL AFTER `irrelevant_get_params`#39;;br /foreach ($sql as $q){br /mysql_query($q, df_db());br /}br /}br /?gt;br //blockquotebr /br /What happens is it will see if the database version is 582 or above and then it will apply this change to the database.  The this general function format can be used for any version numbers.  br /br /To actually setup the database version, we don&apos;t actually need to setup a separate database table to handle this.  We make a version.txt file in the application and xataface will create a version table in the database for us.  The contents of the file will look like this:br /br /blockquotebr /0.1 680br //blockquotebr /br /The 0.1 really means nothing.  It is simply used to note which major release we are on.  It is the second number that means something.  That is the exact version number that gets stored into the database. br /br /And by setting up these two things, it becomes extremely easy to manage the database in xataface!</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Sat Nov 22 14:16:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/11/keeping-your-database-up-to-date.html</source_url>
</news>
<news id="news?news_id=58">
	<news_id>58</news_id>
	<headline>Setting a MD5 hash on a password field</headline>
	<description></description>
	<content>In your users table, you might want to store the user&apos;s password as a MD5 hash.  When xataface is authenticating users, you make to tell them to encrypt the password they enter so that it can be properly compared to the value in the database.  To do this, make a fields.ini file in your user&apos;s table delegate folder.  And then enter this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;[password]&lt;br /&gt;    encryption=md5 &lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;[password] is the name of your password column field name.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Wed Sep  3 00:41:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/09/setting-md5-hash-on-password-field.html</source_url>
</news>
<news id="news?news_id=57">
	<news_id>57</news_id>
	<headline>Adding new sections in a table view</headline>
	<description></description>
	<content>&lt;blockquote&gt;Inside of the actions.ini file, if you want to use a xataface function you have to surround it with semicolons. So for example, {getDealerID()} would return the dealer id.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;So the first thing I wanted to talk about is how to add custom sections to the viewing of a table.  By default, the view of a record in a table will display all the columns for that record.  But what happens if you want to display so other information from another table that had a relationship with that table record?&lt;br /&gt;&lt;br /&gt;For example, say I have a table of companies and this company had a relationship to a table called news.  I could setup a relationship in the relationship.ini file, but this would just create a tab in the record view to go click.  But what if I wanted to view it would having to go into a tab.  Like this:&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://bp2.blogger.com/_FgKT-25Bzvc/R_U5pTS6ywI/AAAAAAAAAwE/GxR9v33UJQ8/s1600-h/xataface.jpg&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;&quot; src=&quot;http://bp2.blogger.com/_FgKT-25Bzvc/R_U5pTS6ywI/AAAAAAAAAwE/GxR9v33UJQ8/s320/xataface.jpg&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5185113927704038146&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The way to do this is to first create a function in the table delegate class to that will retrieve that field.  So basically we make a custom field:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;function field__recent_news(&amp;$record){&lt;br /&gt;  //first parameter is table, &lt;br /&gt;  //second is the where part of the query&lt;br /&gt;  return df_get_records_array(&apos;news&apos;, array(&apos;company_id&apos;=&gt;$record-&gt;val(&apos;company_id&apos;), &apos;owner_type&apos;=&gt;&apos;COMPANY&apos;,&apos;-sort&apos;=&gt;&apos;published_date desc&apos;,&apos;-limit&apos;=&gt;10));&lt;br /&gt; }&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;The df_get_records_array function uses the first parameter as the table we are interested in, and the second parameter is the part used to in the where part of the query.  So in this case, we are using the news table, where we want the company_id of the row equal to the record company id, etc, etc.  Note, we use the -sort here because that is like an action as opposed to a simple additional of a query variable.&lt;br /&gt;&lt;br /&gt;The next part is to add the section function:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;function section__recent_news(&amp;$record){&lt;br /&gt;  &lt;br /&gt;  return array(&lt;br /&gt;   &apos;class&apos;=&gt;&apos;left&apos;,&lt;br /&gt;   &apos;records&apos;=&gt;$record-&gt;val(&apos;recent_news&apos;), //there is a calculated field from the function field_section&lt;br /&gt;   &apos;label&apos;=&gt;&apos;Recent Updates&apos;,&lt;br /&gt;   &apos;url&apos;=&gt;DATAFACE_SITE_HREF.&apos;?-action=list&amp;-table=news&amp;company_id=&apos;.$record-&gt;val(&apos;company_id&apos;).&apos;&amp;owner_type=COMPANY&apos;&lt;br /&gt;  );&lt;br /&gt; }&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;The name of this function can actually be section__XXX, but we just give it a good name.  Here the class attribute means what side it will be displayed in.  The records are what we are grabbing.  So remember that function we made above that makes a custom field, we are now grabbing this field.  I think by default it will display the first column of the table (that is not the primary key or foreign key).  Label is the label of the section, and url is the condition I think the url has to fulfill to make sure that this function gets run.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Thu Apr  3 02:05:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/04/adding-new-sections-in-table-view.html</source_url>
</news>
<news id="news?news_id=73">
	<news_id>73</news_id>
	<headline>Directly modifying a table&apos;s attributes</headline>
	<description></description>
	<content>While using the fields.ini is a good way to set attributes such as widget:label, description, etc sometimes you need more control.  This can be accomplished by loading the table in the code and then directly modifying the fields.  For example:br /br /blockquotebr /$usersTable =amp; Dataface_Table::loadTable(#39;users#39;);br /$myfield =amp; $usersTable-gt;getField(#39;password#39;);br /$myfield[#39;widget#39;][#39;description#39;] = quot;Hello worldquot;;br //blockquotebr /br /The first line of code is retrieving a reference to the users table which is a Xataface table object.  The table object comes with some functions that allow you with.  One of them being the getField() function which would then retrieve a reference to the password field variable.  From there we can access the widget attributes using arrays.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Wed Nov 12 06:42:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/11/directly-modifying-tables-attributes.html</source_url>
</news>
<news id="news?news_id=74">
	<news_id>74</news_id>
	<headline>Using Xataface to create forms</headline>
	<description></description>
	<content>You can leverage off the power of Xataface to create forms allowing users to submit data to your tables.  Here is some code to allow you do that, I&apos;ll go into more explanation after:br /br /blockquotebr /$app =amp; Dataface_Application::getInstance();br /$record =amp; $app-gt;getRecord();br /$form =amp; df_create_edit_record_form($record, array(#39;FirstName#39;,#39;LastName#39;));br /br /$form-gt;addElement(#39;hidden#39;,#39;-action#39;,#39;myaction#39;);br /if ($form-gt;validate() ){br /$res = $form-gt;process(array(amp;$form, #39;save#39;), true);br /// could return false or PEAR_Error to indicate error.br /header(#39;Location: #39;.DATAFACE_SITE_HREF.#39;?-action=fooamp;--msg=Success#39;);br /exit;br /}br /$form-gt;display();br //blockquotebr /br /The first two lines are basically grabbing a reference to the xataface application and the current record loaded.br /br /blockquote$form =amp; df_create_edit_record_form($record, array(#39;FirstName#39;,#39;LastName#39;));br //blockquotebr /br /This line will create a xataface form object which represents the same table that this record is taken from.  It will only display the FirstName and LastName fields though since the second parameter allows you to select which fields to display.  Because it is a edit record form, it will fill in the values of the form with the values from the record that was sent in through the parameter.  You can alternatively use the df_create_new_record_form() to create a new form entirely.  br /br /blockquote$form-gt;addElement(#39;hidden#39;,#39;-action#39;,#39;myaction#/blockquotebr /br /This line adds a hidden element to the form and then sets the name of the hidden element to be -action.  It is basically used to allow the form to figure out what action to take after it has been submitted.  Generally, we set the action to be the same action as the current page and then allow the form to be validate (explained below)br /br /blockquoteif ($form-gt;validate() ){br /$res = $form-gt;process(array(amp;$form, #39;save#39;), true);br /// could return false or PEAR_Error to indicate error.br /header(#39;Location: #39;.DATAFACE_SITE_HREF.#39;?-action=fooamp;--msg=Success#39;);br /exit;br /}/blockquotebr /br /The form first gets validated for valid values.  And then if it returns true, it will then process the form and basically save the data to the database.  From there, we need to redirect the user to the next location.  We always put an exit statement after the header() to make sure the code stops after the redirect.  Because should the redirect for some reason fail, we don&apos;t want the user to be see the form again.br /br /blockquote$form-gt;display();/blockquotebr /br /Finally, if the form was not validated (ie. not submitted before, or values wrong) we need to display form which is what this line does.br /br /And there you go!  That&apos;s how you can use Xataface to help you create forms!</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Fri Nov  7 09:46:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/11/using-xataface-to-create-forms.html</source_url>
</news>
<news id="news?news_id=75">
	<news_id>75</news_id>
	<headline>Using Xataface to search for NULL</headline>
	<description></description>
	<content>If there is a row in a table that contains a NULL value, you can use Xataface to search specifically for that record but it&apos;s not as trivial as searching for NULL.  You have to set it to an equal sign which will basically look for exact matches to nothing.  For example:br /br /blockquote$temp_types = df_get_records_array(&apos;n1_tire_types&apos;, array(&apos;-limit&apos;=200, &apos;parent_id&apos; = &quot;=&quot;));/blockquotebr /br /Will look for columns in the n1_type_types table with a parent_id of empty or NULL.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Fri Nov  7 03:59:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/11/using-xataface-to-search-for-null.html</source_url>
</news>
<news id="news?news_id=76">
	<news_id>76</news_id>
	<headline>Secure Display</headline>
	<description></description>
	<content>If you are using Xataface as your backend management, and also as a front end (through the use of actions and templates) this can save you lots of time.  However, sometimes you set permissions on records that you don&apos;t want users seeing if they are in the backend.  For example, the application could prevent any users not logged in from seeing the backend by returning:br /br /blockquotereturn Dataface_PermissionsTool::NO_ACCESS();/blockquotebr /br /However this could have adverse effects as in the front end some records are no longer viewable because of this.  One way to solve this is to set in each of your smarty templates this small block of code which basically causes all records to ignore all permissions:br /br /blockquotebr /{php}br /$pt = Dataface_PermissionsTool::getInstance();br /$pt-gt;setContext($pt-PUBLIC_CONTEXT());br /{/php}br //blockquote</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Thu Nov  6 13:07:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/11/secure-display.html</source_url>
</news>
<news id="news?news_id=77">
	<news_id>77</news_id>
	<headline>output cache</headline>
	<description></description>
	<content>One of the things you can do on a live xataface site is turn on caching to allow the server to just the information in RAM rather than continue to hit the database for information each time.  You can do this by simply entering this in the conf.ini:br /br /blockquotebr /[_output_cache]br /enabled=1br //blockquotebr /br /But there comes a problem sometimes where you need the data to appear right away and not have the server continue to use the cache (at least until the server refreshes the cache).  If you ever need to do this, you can enter this into manually just modify the url query to include this:br /br /blockquote--refresh-apc=1/blockquotebr /br /This cause the server to automatically hit the database to refresh the cache.  A pretty nice hack.</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Thu Nov  6 13:02:00 2008</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2008/11/output-cache.html</source_url>
</news>
<news id="news?news_id=80">
	<news_id>80</news_id>
	<headline>Setting the access to the templates_c</headline>
	<description></description>
	<content>The templates_c folder is location of where the smarty tag templates are compiled to.  And these templates are used to display the Xataface application.  So it&apos;s important that end-users are able to read from this folder so that they are use the application.  To properly set this up, the templates_c folder should have the 755 permissions:br /br /blockquotechmod 755 templates_c/blockquotebr /br /This basically means that everyone has read and execute access.  And also that the owner has write access to the file/folder.  br /br /You then need to explicitly set the permissions for the user &apos;apache&apos; because end users will be under that username when viewing the application.  To do this:br /br /After that end-users should have no problem viewing the application!</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Mon Feb 16 02:35:00 2009</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2009/02/setting-access-to-templatesc.html</source_url>
</news>
<news id="news?news_id=82">
	<news_id>82</news_id>
	<headline>How to change the label of the save button?</headline>
	<description></description>
	<content>Recently ran into an interesting request on how to change the label of the save button on the edit form to something else.  While I don&apos;t believe there is a direct way to do this in Xataface, you can utilize a little workaround with the feature of &quot;internationalization&quot; of Xataface to get this to work.br /br /How you can do this is:br /olbr /liCreate a &apos;lang&apos; folder in the delegate folder of your class you wish to change the edit form form/libr /liInside that folder, create an en.ini file./libr /liThen add this line:br /blockquotesave_button_label=&quot;Submit&quot;/blockquotebr /What this does is it overrides the label and causes it to say Submit./libr //olbr /br /The real function of this feature is to actually allow the display of that label to differ depending on the language chosen.  In our case, we just override the original label for english (ie. en) and volia!br /br /A nice little work around hey?</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Fri Feb  6 05:13:00 2009</date_posted>
	<posted_by>noreply@blogger.com (Fong Chun Chan)</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="8">Fong&apos;s Blog</source_id>
	<source_url>http://fongxataface.blogspot.com/2009/02/how-to-change-label-of-save-button.html</source_url>
</news>
<news id="news?news_id=62">
	<news_id>62</news_id>
	<headline>Application Versioning &amp; Synchronization with Xataface</headline>
	<description></description>
	<content>	One of the more annoying challenges involved with managing production web applications is keeping the development and production versions in sync.  Verson control systems such as Subversion and CVS make this task trivial for source code and file system changes, but changes to the database schema between versions still need to be handled with [...]</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Wed Nov 26 06:16:49 2008</date_posted>
	<posted_by>shannah</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="1">Steve Hannah&apos;s Blog</source_id>
	<source_url>http://www.sjhannah.com/blog/?p=144</source_url>
</news>
<news id="news?news_id=63">
	<news_id>63</news_id>
	<headline>Replacing Scriptaculous/Prototype with jQuery</headline>
	<description></description>
	<content>	I have used Scriptaculous in the past to sprinkle little bits of UI magic into Xataface.  Specifically, I have used it to add collapsible sections, sortable sections (via drag-and-drop), and sortable tables (also via drag and drop).  These worked great!  The Scriptaculous library was a bit bulky and it made the initial [...]</content>
	<image>/tables/news/image/</image>
	<image_mimetype></image_mimetype>
	<image_caption></image_caption>
	<date_posted>Tue Nov 25 06:34:24 2008</date_posted>
	<posted_by>shannah</posted_by>
	<status value="Approved">Approved</status>
	<categories value="Array">Blog</categories>
	<source_id value="1">Steve Hannah&apos;s Blog</source_id>
	<source_url>http://www.sjhannah.com/blog/?p=143</source_url>
</news></record>