Creating View

Zend Framework Step By Step Tutorial - Part 6: Now, we need to provide a view template for displaying. We will create a index.phtml file. This file is stored within the views/scripts/index. We have a separate directory for each controllers view templates.
Create a file named "index.phtml" within views/scripts/index.
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>
<h1><? echo $this->escape($this->title); ?></h1>
</body>
</html>
The template file is executed within a member function of Zend_View and so $this is available within the template file wich is the gateway to Zend_View's functionality. All variables that have been assigned to the view from within the controller are availabel directly as properties of $this. You can see sample at above, $this->title.

0 comments: