Firebird PHP Generator online Help
Prev | Return to chapter overview | Next |
OnPageLoaded
![](/i/tour-under-title.gif)
This event occurs after the page is completely loaded from the server. It allows you, for example, to add additional filters to the dataset.
Signature:
function OnPageLoaded()
Parameters:
This method has no parameters. |
Example 1
The following code is used in our Schema Browser Demo to filter database objects belonging to the selected database:
applyDatasetFilter($this->dataset);
Here applyDatasetFilter() is a function defined in the schema_browser_utils.php file as follows:
function applyDatasetFilter(Dataset $dataset) {
if (GetApplication()->IsGETValueSet('database'))
$value = GetApplication()->GetGETValue('database');
else
$value = ArrayUtils::GetArrayValueDef($_COOKIE, 'database');
if (StringUtils::IsNullOrEmpty($value)) {
$globalConnectionOptions = GetGlobalConnectionOptions();
$value = $globalConnectionOptions['database'];
}
if (!StringUtils::IsNullOrEmpty($value)) {
$dataset->AddFieldFilter('Database_name', new FieldFilter($value, '='));
setcookie('database', $value);
}
}
Example 2
The following code is used to filter countries by life expectancy:
// default values
$minLifeExpectancy = 40;
$maxLifeExpectancy = 90;
// checking values in the browser address line
if (GetApplication()->isGetValueSet('minLifeExpectancy') &&
GetApplication()->isGetValueSet('maxLifeExpectancy')) {
$minLifeExpectancy = GetApplication()->GetGETValue('minLifeExpectancy');
$maxLifeExpectancy = GetApplication()->GetGETValue('maxLifeExpectancy');
} // or (if not found) in the session
elseif (GetApplication()->IsSessionVariableSet('minLifeExpectancy') &&
GetApplication()->IsSessionVariableSet('maxLifeExpectancy')) {
$minLifeExpectancy = GetApplication()->GetSessionVariable('minLifeExpectancy');
$maxLifeExpectancy = GetApplication()->GetSessionVariable('maxLifeExpectancy');
}
// applying filter to the dataset
$this->dataset->AddCustomCondition(
"life_expectancy >= {$minLifeExpectancy} ".
"AND life_expectancy <= {$maxLifeExpectancy}");
// saving calculated values to the session
GetApplication()->SetSessionVariable('minLifeExpectancy', $minLifeExpectancy);
GetApplication()->SetSessionVariable('maxLifeExpectancy', $maxLifeExpectancy);
See also: OnPreparePage.
Prev | Return to chapter overview | Next |