profile page
From SkyPHP
page | listing page | profile page
A profile page is a page that is used for editing a specific record -- or inserting a new record.
Contents |
Anatomy of a Profile Page
- page settings - settings for a page
- IDE - indicates the id of the record to be displayed (see database schema)
- title - set $title before including the template
- model - specifies all the data fields, and required fields
- form - html form
- validation - prompts user to correct invalid data
- save_form - html button saves data to database using ajax
- template
Example Intranet Profile Page (editable form)
/admin/person/person-profile.php
<?
$model = 'person';
$r = aql::profile($model,IDE);
$primary_table = aql::get_primary_table($model);
if (is_numeric($r[$primary_table.'_id'])) $title = $r['fname'] . ' ' . $r['lname'];
else $title = 'Add New Person';
template::inc('intranet','top');
aql::form($model);
?>
<input type="button" value="Save" onclick="save_form('<?=$model?>');" />
<?
template::inc('intranet','bottom');
?>
Example Website Profile Page (read-only w/ tabs)
/person/person-profile.php
<?
$model = 'person';
$r = aql::profile($model,IDE);
$title = $r['fname'] . ' ' . $r['lname'];
template::inc('website','top');
snippet::tabs(array(
'First Tab' => URLPATH . 'first-tab',
'Second Tab' => URLPATH . 'second-tab'
));
include( INCPATH . 'first-tab.php' );
template::inc('website','bottom');
?>
PHP Functions
- aql::form() - display a form
- aql::profile() - return a single row recordset
- aql::get_primary_table() - return the primary table of the model
- snippet::tabs() - display navigational tabs
- template::inc() - include a portion of a template
Javascript Functions
- save_form() - submit a form (and optionally redirect to another page)
