[PHP] PHP statt Frames
#11
das mit php statt frames is ja ganz lustig aber wenns mal was anständiges machen wollts versucht es mal mit php fast template
http://www.thewebmasters.net/php/FastTemplate.phtml
die template dateien eines wbb2 scheinen eine erweiterte form davon zu sein oder zumindest sowas ähnliches (i hab bis jetzt noch nichts gefunden um variablen direkt in a tpl einzufügen musst die vorher immer parsen)

Zitat:This example will build an HTML page that will consist of a table. The table will have 3 numbered rows. The first step is to decide what templates we need. In order to make it easy for the table to change to a different number of rows, we will have a template for the rows of the table, another for the table, and a third for the head/body part of the HTML page.
Below are the templates. (Pretend each one is in a separate file.)


<!-- NAME: main.tpl -->
<html>
<head><title>{TITLE}</title>
</head>
<body>
{MAIN}
</body>
</html>
<!-- END: main.tpl -->


<!-- NAME: table.tpl -->
<table>
{ROWS}
</table>
<!-- END: table.tpl -->


<!-- NAME: row.tpl -->
<tr>
<td>{NUMBER}</td>
<td>{BIG_NUMBER}</td>
</tr>
<!-- END: row.tpl -->

Now we can start coding...


/* START */


<?
include("class.FastTemplate.php3");
$tpl = new FastTemplate("/path/to/templates");
$tpl->define( array( main => "main.tpl",
table => "table.tpl",
row => "row.tpl" ));


$tpl->assign(TITLE,"FastTemplate Test");


for ($n=1; $n <= 3; $n++)
{
$Number = $n;
$BigNum = $n*10;
$tpl->assign( array( NUMBER => $Number,
BIG_NUMBER => $BigNum ));


$tpl->parse(ROWS,".row");
}
$tpl->parse(MAIN, array("table","main"));
Header("Content-type: text/plain");
$tpl->FastPrint();
exit;
?>


When run it returns:


<!-- NAME: main.tpl -->
<html>
<head><title>FastTemplate Test</title>
</head>
<body>
<!-- NAME: table.tpl -->
<table>
<!-- NAME: row.tpl -->
<tr>
<td>1</td>
<td>10</td>
</tr>
<!-- END: row.tpl -->
<!-- NAME: row.tpl -->
<tr>
<td>2</td>
<td>20</td>
</tr>
<!-- END: row.tpl -->
<!-- NAME: row.tpl -->
<tr>
<td>3</td>
<td>30</td>
</tr>
<!-- END: row.tpl -->

</table>
<!-- END: table.tpl -->


</body>
</html>
<!-- END: main.tpl -->

If you're thinking you could have done the same thing in a few lines of plain PHP, well yes you probably could. But, how would a graphic designer tweak the resulting HTML? How would you have a designer editing the HTML while you're editing another part of the code? How would you save the output to a file, or pipe it to another application? How would you make your application multi-lingual? How would you build an application that has options for high graphics, or text-only? FastTemplate really starts to shine when you are building mid to large scale web applications, simply because it begins to seperate the application's generic logic from the specific implementation.

schaut zwar kompliziert aus is aber extrem flexibel und sauschnell
Write this on my gravestone, write this right on my grave, "To whisky and women, here lies a poor slave".

[Bild: 10_en_btn.gif]

Computer- und Mediensicherheit - FH Hagenberg
Hagenberger Kreis zur Förderung der digitalen Sicherheit
Security Forum
  Zitieren


Nachrichten in diesem Thema
[PHP] PHP statt Frames - von brunner - 17.04.2003, 07:19
[Kein Betreff] - von pattex - 17.04.2003, 07:39
[Kein Betreff] - von Zerogiven - 17.04.2003, 07:49
[Kein Betreff] - von pattex - 17.04.2003, 07:59
[Kein Betreff] - von Zerogiven - 17.04.2003, 08:00
[Kein Betreff] - von brunner - 17.04.2003, 08:28
[Kein Betreff] - von pattex - 17.04.2003, 08:32
[Kein Betreff] - von pattex - 18.04.2003, 18:39
[Kein Betreff] - von Zerogiven - 19.04.2003, 12:33
[Kein Betreff] - von pattex - 19.04.2003, 13:51
[Kein Betreff] - von kickedINtheHEAD - 20.04.2003, 22:22
[Kein Betreff] - von Zerogiven - 20.04.2003, 22:58
[Kein Betreff] - von kickedINtheHEAD - 20.04.2003, 23:00
[Kein Betreff] - von Zerogiven - 20.04.2003, 23:03
[Kein Betreff] - von kickedINtheHEAD - 20.04.2003, 23:05

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 2 Gast/Gäste