[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
#12
Templates sind aber zum vergleichen mit includes, im Prinzip wenn man anständige includes macht, hat man den selben Effekt wie bei Templates.

mfg
Zerogiven
<a href="http://www.boldluck.at" target="_blank">
[Bild: boldluck468603.gif] </a>
  Zitieren
#13
dacht ich ma schon das des jetzt kommt antwort dazu steht oben sogar schon auf englisch im zitat dabei Wink

Zitat:
Zitat: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.
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
#14
O.K. In der Situation geb ich dir recht, aber das jemand hier reinschaut, wenn er was grösseres macht.....

Das glaub ich eher kaum. Hier wird es eher um kleinere Seiten gehen, und da genügen "normale" includes auch. (Aber sonst geb ich dir recht)

mfg
Zerogiven
<a href="http://www.boldluck.at" target="_blank">
[Bild: boldluck468603.gif] </a>
  Zitieren
#15
i fang au schon an mit kleineren seiten so zu arbeiten da ich immer mit an kumpl zusammenarbeit
ich mach die php programmierung und sonstiges zeug und er macht as design
er selber mag einfach den php code net so gern und des verwirrt wennst die html seite aufbaust total
und au beim ändern bist viel schneller
is einfach ne speziallisierung damit was besseres rauskommt
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


Gehe zu:


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