component
From SkyPHP
A "component" is a php file that outputs HTML formatted data. The data is array variable $r.
Components are stored in the /components folder and named with specific folder and file naming conventions.
For example:
/components/ {table name} / {field name} / {alias} .php
Components are commonly used with aql grid to display data in the cells of the grid.
Example Components on a Grid
The columns string indicates which components are used.
<?
aql::grid(array(
'aql' => "
album {
id as album_info,
name as album_name,
year,
duration
}
artist {
name as artist_name
}",
'columns' => "
album_info {
label: Album;
order by: album.sort_name;
}
edit {} ",
'where' => 'artist.name = Pink Floyd',
'order by' => 'album.year desc'
));
?>
The first column (album_info) is displayed using the following component:
/components/album/id/album_info.php
<div class="album_info">
<div class="album_name"><?=$r['album_name']?></div>
<div class="artist_name"><?=$r['artist_name']?></div>
<div class="year"><?=$r['year']?></div>
</div>
The second column, edit, is a global component that will display a button that links to the [[profile page]].
Example COMPONENTS on Listing Page
Each column is globally limited because it is only set to display data from any field in the table. This limitation is overcome with the use of "Components" as columns on a listing pages -- customizes a column. Components can simply format data or run complex scripts including Ajax.
Creating a component uses the following convention: (fields must be in the aql model) A component altering a single field is placed according to:
- folder with the table name
- sub-folder with the field name
- file using the field-name.php
THE ID FOLDER - use for multiple fields: If the component is placed in an "id folder", there is NO sub-folder, use file name with identifier such as location.php (address, city, state, zipcode fields). When creating a component in the "id folder" you need to add it to the model: id as location When naming the component in the id folder: DO NOT USE A FIELD NAME IT WILL CAUSE AN ERROR: "id as source" in the aql when there is a field called source
When a component needs a path: script: components/deal/mls_agent_id/mls_agent_id.php; note: no leading /
See details: components
Trick: If you have a nested table in your model, the nested table name becomes a field in the recordset. You may create a component sub-folder for the nested table name.
