Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arin Sarkissian
authored and
Arin Sarkissian
committed
May 10, 2009
1 parent
6aa6e67
commit a316175
Showing
10 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php foreach($cars as $car) : ?> | ||
<p> | ||
make: <?php echo $car['make']; ?> <br /> | ||
model: <?php echo $car['model']; ?> <br /> | ||
year: <?php echo $car['year']; ?> | ||
</p> | ||
<?php endforeach; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
// using the template with a header & footer | ||
|
||
|
||
// rig up the include_path | ||
set_include_path( | ||
realpath('../') . | ||
PATH_SEPARATOR . | ||
realpath('./') | ||
); | ||
|
||
require_once('ExampleTemplate.php'); | ||
|
||
// make an array for cars for the template1.php file to spit put | ||
$cars = array( | ||
array('make' => 'vw', 'model' => 'bug', 'year' => '1966'), | ||
array('make' => 'audi', 'model' => 'a4', 'year' => '2009') | ||
); | ||
|
||
// the template files ('template1.php', 'header1.php', 'footer1.php') | ||
// will all have access to variables called $foo and $cars | ||
$templateData = array( | ||
'foo' => 'howdy', | ||
'cars' => $cars | ||
); | ||
|
||
// render the template | ||
$t = new ExampleTemplate('template1.php', $templateData, 'header1.php', 'footer1.php'); | ||
$t->render(); | ||
|
||
// get the output of the template as a string | ||
$stringValueOfTemplate = $t->render(true); | ||
// var_dump $stringValueOfTemplate to see we captured the output as a string | ||
var_dump($stringValueOfTemplate); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
// using the template with a header & footer AND including another template | ||
|
||
// rig up the include_path | ||
set_include_path( | ||
realpath('../') . | ||
PATH_SEPARATOR . | ||
realpath('./') | ||
); | ||
|
||
require_once('ExampleTemplate.php'); | ||
|
||
// make an array for cars for the template1.php file to spit put | ||
$cars = array( | ||
array('make' => 'vw', 'model' => 'bug', 'year' => '1966'), | ||
array('make' => 'audi', 'model' => 'a4', 'year' => '2009') | ||
); | ||
|
||
// the template files ('template2.php', 'header1.php', 'footer1.php') | ||
// will all have access to variables called $foo and $cars | ||
$templateData = array( | ||
'foo' => 'howdy', | ||
'cars' => $cars | ||
); | ||
|
||
// get the template's output but dont render yet | ||
$t = new ExampleTemplate('template2.php', $templateData, 'header1.php', 'footer1.php'); | ||
$output = $t->render(true); | ||
|
||
echo $output; // or echo $t would have worked... | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<hr /> | ||
<div style="text-align: center">i am a footer</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>I am a header file.</h1> | ||
<p>the value of $foo is <?php echo $foo ?></p> | ||
<hr /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div style="border: 2px solid #666; padding: 10px"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<p> | ||
I am the template file. wuddup??? | ||
</p> | ||
|
||
<?php foreach($cars as $car) : ?> | ||
<p> | ||
make: <?php echo $car['make']; ?> <br /> | ||
model: <?php echo $car['model']; ?> <br /> | ||
year: <?php echo $car['year']; ?> | ||
</p> | ||
<?php endforeach; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<p> | ||
I am the template file. wuddup??? | ||
</p> | ||
|
||
<?php | ||
// all the variables available to this template will get passed to the new one | ||
$this->inc('carsTemplate.php', 'header2.php', 'footer2.php'); | ||
?> |