Booosta Tutorial
Simple Example
This example shows a very simple application that just manipulates the data in a database table
index.php:
<?php
include_once 'lib/framework.incl.php';
class App extends Webapp
{
protected $name = 'person';
protected $toptpl = '';
}
$app = new App();
$app->run();
?>
- Line 2: Include the booosta framework in every PHP file
- Line 4: Extend the Webapp class
- Line 6: Set the propery "name" to the name of the database table
- Line 7: If you do not use nested templates you have to set the class property "toptpl" to ''
- Line 10, 11: Create an object and call method run()
tpl/person_default.tpl:
<h1>Persons</h1>
{LINK New~person index.php?action=new}
{%liste}
- Line 3: Make a link to the PHP script and set parameter "action" to new to create a new record
- Line 5: Show content of the template variable "liste", which is auto created
tpl/person_new.tpl:
<h1>New Person<h1>
{FORMSTART index.php}
{HIDDEN action newdo}
<table>
<tr><td>Firstname </td><td>{TEXT firstname}</td></tr>
<tr><td>Lastname </td><td>{TEXT lastname}</td></tr>
<tr><td>Email </td><td>{TEXT email}</td></tr>
<tr><td>Street </td><td>{TEXT street}</td></tr>
<tr><td>City </td><td>{TEXT city}</td></tr>
<tr><td>Postcode</td><td>{TEXT postcode}</td></tr>
</table>
<br><br>
{FORMSUBMIT}
{FORMEND}
tpl/person_edit.tpl:
<h1>Edit Person</h1>
{FORMSTART index.php}
{HIDDEN action editdo}
{HIDDEN id {%id}}
<table>
<tr><td>Firstname </td><td>{TEXT firstname {%~firstname}}</td></tr>
<tr><td>Lastname </td><td>{TEXT lastname {%~lastname}}</td></tr>
<tr><td>Email </td><td>{TEXT email {%~email}}</td></tr>
<tr><td>Street </td><td>{TEXT street {%~street}}</td></tr>
<tr><td>City </td><td>{TEXT city {%~city}}</td></tr>
<tr><td>Postcode</td><td>{TEXT postcode {%~postcode}}</td></tr>
</table>
<br><br>
{FORMSUBMIT}
{FORMEND}