This example shows nicely how you can make different views and navigate with them. Every view is embedded in a function which can be called with a click event on the button. We also have a choice element an we will see how we can use it in several views.
the code:
< php
require_once('ippfp/ippfp.php');
$ippfp->run();
$myChoice = $ippfp->createChoice("",
array(1 => "Dresden", 2 => "Prague", 3 => "San Jose"),"myChoice");
function start($value = null){
global $ippfp;
global $myChoice;
$myView = $ippfp->createView("my view");
$myView->insert($myChoice);
$myView->insert($ippfp->createButton("finish","","","myButton");
$ippfp->process($myView);
}
function finish($value = null){
global $ippfp;
global $myChoice;
$myView = $ippfp->createView("my second view");
$myView->insert($myChoice->getValue());
$ippfp->process($myView);
}
?>
include the library:
require_once('ippfp/ippfp.php');
call this function to start:
$ippfp->run();create a choice element:
$myChoice = $ippfp->createChoice("",array(1 => "Dresden", 2 => "Prague", 3 => "San Jose"),"myChoice");
start(), create a view:
function start($value = null){
global $ippfp;
global $myChoice;
$myView = $ippfp->createView("my view");
insert the choice element:
$myView->insert($myChoice);create and insert a button:
$myView->insert($ippfp->createButton("finish","","","myButton");
process:
$ippfp->process($myView);finish():
function finish($value = null){
global $ippfp;
global $myChoice;
$myView = $ippfp->createView("my second view");
Insert the currently value into the view (it will be converted automatically into a label element):
$myView->insert($myChoice->getValue());process:
$ippfp->process($myView);
In this example we will see how we can use several buttons to call the same view with different values.
the code:
< php
require_once('ippfp/ippfp.php');
$ippfp->run();
function start($value){
global $ippfp;
$myView = $ippfp->createView("my view");
$myView->insert($ippfp->createButton("start", "1", "", "button_1_name");
$myView->insert($ippfp->createButton("start", "2", "", "button_2_name");
$myView->insert($ippfp->createLabel($value);
$ippfp->process($myView);
}
?>
create two buttons, the second attribute could be an additional value which can be accessed in the called view:
$myView->insert($ippfp->createButton("start", "1", "", "button_1");
$myView->insert($ippfp->createButton("start", "2", "", "button_2");
Readout the values. If we press button 1 the value will be 1, similar to button 2 and 2. Values will be given as function value.
function start($value){
...
$myView->insert($value);
...
}