-
Notifications
You must be signed in to change notification settings - Fork 1
Layout Example
Swaroop SM edited this page Jun 29, 2014
·
4 revisions
This is an example of using layouting for your template.
Create 3 files:
- layout.php
- template.php
- sample.php
Open layout.php
and paste the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tower</title>
</head>
<body>
<?= $yield ?>
</body>
</html>
Open template.php
and paste the following code:
<h1><?= $name ?></h1>
<p><?= $age ?></p>
Open sample.php
and paste the following code:
<?php
require 'vendor/autoload.php';
$tower = new Tower();
$tower->setLayout('layout.php');
$tower->setTemplate('template.php');
$tower->set('name', 'Swaroop SM');
$tower->set('age', 24);
$tower->set('profession', 'Software Developer');
$tower->render();
Open sample.php
on your browser.
--gg