| 28 | |
| 29 | == Simple example == |
| 30 | Suppose 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 | |
| 43 | include "../ef.php"; |
| 44 | ef_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> |
| 53 | Output of myapp1: <?= ef_tpl($myapp1) ?> |
| 54 | Output of myapp2: <?= ef_tpl($myapp2) ?> |
| 55 | </html> |
| 56 | }}} |
| 57 | |
| 58 | === myapp/action.php and myapp/foo/action.php === |
| 59 | {{{ |
| 60 | <?php |
| 61 | ef_outputs("myvar", "myarg"); |
| 62 | |
| 63 | $myvar = "level 1"; |
| 64 | $myarg = $req["arg1"]; |
| 65 | }}} |
| 66 | |
| 67 | {{{ |
| 68 | <?php |
| 69 | ef_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> |
| 90 | Output of myapp1: Hi there! -- myvar = level 1, myarg = |
| 91 | Output of myapp2: Hi there! -- myvar = level 1 and level 2, myarg = hello world |
| 92 | </html> |
| 93 | }}} |