BIF3
[ class tree: BIF3 ] [ index: BIF3 ] [ all elements ]
Prev Next
Creating More WidgetsMore complex widgets

The HelloWorld widget was quite simple. Useless in many ways. Maybe a welcome message is quite more useful for an application. We want the user to feel confortable using our application.

lets start creating the template -skin- file: Skins/Default/welcome.tpl
Welcome to <b>{SITE}</b>, located in {LOCATION}!<br>
<br>
It's great to have you here, we ain't got much more to offer but our
kindness. Come back again, later, we'll keep on BIFing.

Of course our Welcome widget still being as simple as HelloWorld, this is file Widgets/Welcome.php
class Welcome extends BifWidget {
  function Welcome ($attrs = array()) {
    $this->BifWidget($attrs);
  }
  function innerDraw() {
    $this->RawFields=array('SITE','LOCATION');
  }
}

Now in order to use it we must create a welcome_page.bif file. as follows:
<BifRoot>
<Welcome site="www.lunix.com.ar" location="Santa Fe, Argentina" />
</BifRoot>

I won't detail how to use render_file(), because I did it in the previous tutorial Creating Widgets.

Let's chage the look a little bit by adding a box this a title with TitleBox, welcome_page.bif will be:
<BifRoot>
<TitleBox title="Welcome">
<Welcome site="www.lunix.com.ar" location="Santa Fe, Argentina" />
</TitleBox>
</BifRoot>

Mmmh is no THAT diferent! let's chage the skin, edit skins.txt file in your application directory
#  file 'skins.txt': User configuration file
#  ----------------------------------------------
#  
#  This file has skins configuration.
#  They are listed in order to be included.
#  must exist either
#      "$sys_dir/Skins/$skin.php" 
#  or
#      "$app_dir/Skins/$skin.php" 
SkinDefault
SkinAqua

Now should be much nicer!! Just as a try, we want to welcome our users not once, but TWICE, because we like them very much. Chage welcome_page.bif like this:
<BifRoot>
<TitleBox title="Welcome">
<Welcome site="www.lunix.com.ar" location="Santa Fe, Argentina" />
</TitleBox>
<TitleBox title="Second Welcome">
<Welcome site="www.another.com" location="Montevideo, Uruguay" />
</TitleBox>
</BifRoot>

Or fit it into a two-column table:
<BifRoot>
<table>
<tr>
<td>
<TitleBox title="Welcome">
<Welcome site="www.lunix.com.ar" location="Santa Fe, Argentina" />
</TitleBox>
</td>
<td>
<TitleBox title="Second Welcome">
<Welcome site="www.another.com" location="Montevideo, Uruguay" />
</TitleBox>
</td>
</tr>
</table>
</BifRoot>

Conclusion:

In case you have to maintain a software, touching .php files could be tedious, and sometimes trying to fix a bug you create another one.

Dot bif files make life much simpler, even somebody that doesn't know PHP can maintain the major part of the application.

Prev   Next
Changing the look Creating Widgets

Documentation generated on Wed, 10 Nov 2004 19:41:18 -0300 by phpDocumentor 1.2.3