intro
Let’s create simple layout using Zend_Layout.You can download the source code of this article from here.
1.Create bootstrap.php
Create the file
application/bootstrap.php
with the following content.
1 2 3 4 5 6 7 8 9 |
<?php set_include_path('../library' . PATH_SEPARATOR . get_include_path()); require_once 'Zend/Controller/Front.php'; require_once 'Zend/Layout.php'; $layout = Zend_Layout::startMvc(); //$layout->getView()->baseUrl = '/yourBaseUrl'; Zend_Controller_Front::run('../application/controllers'); |
2.Create Layout
Create the file
Create the file
Create the file
Create the file
Create the file
application/views/scripts/layout.phtml
with the following content.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Simple Layout Site</title> <link href="<?= $this->baseUrl?>/css/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="header"><?= $this->render('layouts/header.phtml') ?></div> <div id="nav"><?= $this->render('layouts/nav.phtml') ?></div> <div id="content"><?= $this->layout()->content ?></div> <div id="footer"><?= $this->render('layouts/footer.phtml') ?></div> </body> </html> |
Create the file
application/views/scripts/layout/header.phtml
with the following content.
1 |
<p>Simple Layout Site</p> |
Create the file
application/views/scripts/layout/nav.phtml
with the following content.
1 2 3 4 5 6 7 8 9 |
<dl> <dt>Pages</dt> <dd> <ul> <li><a href="page1.html">Page 1</a></li> <li><a href="page2.html">Page 2</a></li> </ul> </dd> </dl> |
Create the file
application/views/scripts/layout/footer.phtml
with the following content.
1 |
<address>Copyright © Simple Layout Site All Rights Reserved.</address> |
Create the file
public/css/style.css
with the following content.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#header { width: 100%; border-bottom: 1px solid #cccccc; } #nav { width: 33%; float: right; } #content { width: 66%; float: left; } #footer { width: 100%; float: none; clear: both; text-align: center; font-size: 10pt; border-top: 1px solid #cccccc; } |
3.Create Controller and View
Create the file
Create the file
application/controllers/IndexController.php
with the following content.
1 2 3 4 5 6 7 8 |
<?php require_once 'Zend/Controller/Action.php'; class IndexController extends Zend_Controller_Action { public function indexAction() { } } |
Create the file
application/views/scripts/index/index.phtml
with the following content.
1 |
<p>This is content</p> |
Thank you……