-
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 a quick example on using Tower. Firstly, follow the README on installing Tower.
Create 2 files:
- template.php
- sample.php
Open template.php
and paste the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h2><?= $name ?></h2>
<p><?= $age ?></p>
<code><?= $profession ?></code>
</body>
</html>
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();
//layout.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tower</title>
</head>
<body>
<?= $yield ?>
</body>
</html>
//template.php
<h1><?= $name ?></h1>
<p><?= $age ?></p>
Open sample.php
on your browser and enjoy. 😃
--gg