- 2008-04-08 (Tue) 7:00
- Zend_Layout
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.
<?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
application/views/scripts/layout.phtml with the following content.
<!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.
Simple Layout Site
Create the file application/views/scripts/layout/nav.phtml with the following content.
<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.
<address>Copyright © Simple Layout Site All Rights Reserved.</address>
Create the file public/css/style.css with the following content.
#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
application/controllers/IndexController.php with the following content.
<?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.
This is content
Comments:1
- ragavendran 09-02-12 (Thu) 19:33
-
Thank you……
Trackbacks:0
- Trackback URL for this entry
- http://www.oplabo.com/article/14/trackback
- Listed below are links to weblogs that reference
- Simple Layout using Zend_Layout from Open Programming Laboratory
