phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Zend Framework Intro: Creating View

Tag: framework, zend, zend framework, access file, view, MVC   Category: PHP Framework
post: 09 Apr 2008 read: 2,259


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.



Series this article:
Zend Framework Intro: Folder Structure
Zend Framework Intro: Explaining Anatomy of Zend Framework Application
Zend Framework Intro: Creating Index.php as Single Access File
Zend Framework Intro: Creating Apache .htaccess
Zend Framework Intro: Creating Controller
Zend Framework Intro: Creating View

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting