Zend Framework Action: Including Header and Footer


Zend Framework Action Step By Step Tutorial - Part 5: Last posting from this series, we talk about how to include header and footer for template. I know, may be this is not any relation with Zend Framework Action, but, may be this knowledge become useful for you to build web site now.

Create a file named "header.phtml" within views/scripts/user. Enter following code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? echo $this->escape($this->title); ?></title>
</head>
<body>
<div id="header">
My Zend Framework
</div>

Now, create a file named "footer.phtml" within views/scripts/user. Enter following code:

<div id="footer">
By PHPEveryday.com
</div>
</body>
</html>

Last, update "name.phtml" within views/scripts/user with this:

<? include "header.phtml"; ?>
  <h1><?=$this->escape($this->title);?>, <?=$this->escape($this->name);?></h1>
  <h2>Gender: <?=$this->escape($this->gender);?></h2>
<? include "footer.phtml"; ?>

Now, try to point your browser to http://localhost/test/zend/helloworld/web_root/user/ name/username/wiwit/gender/man



Series this article:
Zend Framework Action: Dynamic Content
Zend Framework Action: URL Structure and Controller
Zend Framework Action: URL Structure and Action
Zend Framework Action: GET Parameters
Zend Framework Action: Including Header and Footer

Bookmark and Share Tag: framework, zend, zend framework, view, MVC, action, header, footer Category: PHP Framework Post : April 11th 2008 Read: 23,948

blog comments powered by Disqus