Changes between Version 4 and Version 5 of WikiStart

Show
Ignore:
Author:
pjf (IP: 83.230.1.136)
Timestamp:
02/18/10 19:43:06 (7 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WikiStart

    v4 v5  
    2626 
    2727Once the path end is reached, an object holding all exported variables and template structure is returned. The data may be further "poured" into HTML templates or directly exported in JSON format. 
     28 
     29== Simple example == 
     30Suppose you have following file structure: 
     31 * htdocs/index.php - so called "interface" 
     32 * ef.php - ef source code 
     33 * myapp/ - exemplary application 
     34   * myapp/action.php 
     35   * myapp/foo/action.php 
     36   * myapp/block-main.php 
     37   * myapp/lang.pl.php 
     38 
     39=== htdocs/index.php === 
     40{{{ 
     41<?php 
     42 
     43include "../ef.php"; 
     44ef_init(); 
     45 
     46$myapp1 = ef_run("/myapp"); 
     47$myapp2 = ef_run("/myapp/foo", array("arg1" => "hello world")); 
     48 
     49?> 
     50<html> 
     51<head><title>Hi there</title></head> 
     52<body> 
     53Output of myapp1: <?= ef_tpl($myapp1) ?> 
     54Output of myapp2: <?= ef_tpl($myapp2) ?> 
     55</html> 
     56}}} 
     57 
     58=== myapp/action.php and myapp/foo/action.php === 
     59{{{ 
     60<?php 
     61ef_outputs("myvar", "myarg"); 
     62 
     63$myvar = "level 1"; 
     64$myarg = $req["arg1"]; 
     65}}} 
     66 
     67{{{ 
     68<?php 
     69ef_outputs("myvar"); 
     70 
     71$myvar .= " and level 2"; 
     72}}} 
     73 
     74=== myapp/block-main.php === 
     75{{{ 
     76<?= t("Hi there!") ?> -- myvar = <?= $myvar ?>, myarg = <?= $myarg ?> 
     77}}} 
     78 
     79=== myapp/lang.pl.php === 
     80{{{ 
     81<?php 
     82$a = array("Hi there!" => "Cześć!"); 
     83}}} 
     84 
     85=== Output === 
     86{{{ 
     87<html> 
     88<head><title>Hi there</title></head> 
     89<body> 
     90Output of myapp1: Hi there! -- myvar = level 1, myarg =  
     91Output of myapp2: Hi there! -- myvar = level 1 and level 2, myarg = hello world 
     92</html> 
     93}}}