Thursday, April 23, 2009

Aptana IDE for Xataface

I've spent most of my development time simply using Notepad++ simply because it's so fast and just gets the job done. But I decided to try something different and actually get some sort of IDE for my development one that could recommend me the Xataface functions/classes to use.

I heard about this IDE called Aptana which was designed specifically for web development decided to give it a try. And after trying it out and setting it up with Xataface, I must say it is really wicked.

To set it up to work with Xataface is really simple:


  1. First download Aptana from http://www.aptana.com/. You can get it as standalone or as a plugin to Eclipse. Doesn't matter. I downloaded the .zip file as I try to avoid installers as much as possible.

  2. After it has downloaded, just go to the folder and start up Aptana by clicking on the .exe file. A slashscreen will appear and Aptana will start setting up some folders and configuration files on your computer. And after a few seconds, you'll be brought to the Aptana application frontpage.

  3. The tab you are on should be the "My Aptana" tab. Next, click "Plugins" and then you will see "Aptana PHP" and then click on get it. It will start downloading and install the PHP plugin for Aptana.

  4. After this is done, you'll need to tell Aptana to use the libraries/class of Xataface in it's php autocomplete. This is very simple. Go to:

    Windows->Preferences->Aptana->Editors->PHP->PHP Libraries.

    Now add the folder where Xataface is and then called the library name whatever you want (I called it Xataface Framework).

  5. Now when you start a PHP project, and a php file. You can start typing any Xataface class and it will recognize the class and recommend it as well as the syntax!



This is really good as Xataface as never been officially documented to use any IDE. I'll continue to keep posting about my experiences and any tips/tricks I learn along the way.

Editing the userchrome.css file

I recently discovered something really helpful in Firefox called the userchrome.css file. By editing this file you can add some pretty slick styling features to your Firefox browser to help you browse the web. For example, I was able to disable the forward and backward buttons when they weren't necessary. This tutorial is of very good help.

Here is the userchrome.css file I customed myself:

Thursday, April 9, 2009

How to access the conf.ini fields

Xataface will load all the attributes in the conf.ini and use them to setup the application. But what happens if you decide to store some attributes in the conf.ini yourself that Xataface itself doesn't need, but you would like to use it during the execution of your code?

Say for example, you have this:



Here we have a database connection that you would like to use to connect to another database [other than the one that xataface is using to setup the application]. The code to access it:



The Xataface_Application object has attribute which you can access which then contains the entire conf.ini data in an array-array.

Very useful!

Display a 0 value

In Xataface, if the column in the database is of integer type and the row has a 0 value in that column then it would be displayed in the view tab. Normally this isn't a problem and actually nice because then it won't clutter up the screen. But sometimes you actually need to display this 0 value. To solve this, you can just use the field__htmlValue function to override the default function execution:



Here we have this field called 'single_conference_delay' which signifies how long it will take before the conference starts. And it's important to specify if it starts immediately like 0 days. This code will display it.

Using the echo <<<

Have you ever had the case where you need to echo a lot of things in PHP, but using the echo function just took too long because of all the quotes and stuff. Well there is a way to to echo things in PHP that makes it a lot easier. It is called the "here document" syntax:



The END (any word actually works) on the first line acts a document terminator to tell when the text has stopped. So the the the last line can't have anything else on it except for END

For example:



See this link for more details.