Zend Framework の紹介

 Learning Zend Framework

appendix

 Zend Framework リファレンス


  • 第36章 Zend_Gdata
  • 第37章 Zend_Http
  • 第38章 Zend_InfoCard
  • 第39章 Zend_Json
  • 第40章 Zend_Layout
  • 第41章 Zend_Ldap
  • 第42章 Zend_Loader
  • 第43章 Zend_Locale
  • 第44章 Zend_Log
  • 第45章 Zend_Mail
  • 第46章 Zend_Markup
  • 第47章 Zend_Measure
  • 第48章 Zend_Memory
  • 第49章 Zend_Mime
  • 第50章 Zend_Navigation
  • 第51章 Zend_Oauth
  • 第52章 Zend_OpenId
  • 第53章 Zend_Paginator
  • 第54章 Zend_Pdf
  • 第55章 Zend_ProgressBar
  • 第56章 Zend_Queue
  • 第57章 Zend_Reflection
  • 第58章 Zend_Registry
  • 第59章 Zend_Rest

  • 第60章 Zend_Search_Lucene
  • 第61章 Zend_Serializer
  • 第62章 Zend_Server
  • 第63章 Zend_Service
  • 第64章 Zend_Session
  • 第65章 Zend_Soap
  • 第66章 Zend_Tag
  • 第67章 Zend_Test
  • 第68章 Zend_Text
  • 第69章 Zend_TimeSync
  • 第70章 Zend_Tool
  • 第71章 Zend_Tool_Framework
  • 第72章 Zend_Tool_Project
  • 第73章 Zend_Translate
  • 第74章 Zend_Uri
  • 第75章 Zend_Validate
  • 第76章 Zend_Version
  • 第77章 Zend_View
  • 第78章 Zend_Wildfire
  • 第79章 Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Translation 70.6% Update 2010-11-28 - Revision 23415

    第6章 Getting Started with Zend_Layout

    6.1. Introduction

    When building a website using Zend Framework MVC layers, your view scripts will typically be just snippets of HTML pertinent to the requested action. For instance, if you had the action "/user/list", you might create a view script that iterates through the users and presents an unordered list:

    <h2>Users</h2>
    <
    ul>
        <?
    php if (!count($this->users)): ?>
        <li>No users found</li>
        <?php else: ?>
        <?php foreach ($this->users as $user): ?>
        <li>
            <?php echo $this->escape($user->fullname?>
            (<?php echo $this->escape($user->email?>)
        </li>
        <?php endforeach ?>
        <?php endif ?>
    </ul>

    Since this is just a snippet of HTML, it's not a valid page; it's missing a DOCTYPE declaration, and the opening HTML and BODY tags. So, the question is, where will these be created?

    In early versions of Zend Framework, developers often created "header" and "footer" view scripts that had these artifacts, and then in each view script they would render them. While this methodology worked, it also made it difficult to refactor later, or to build composite content by calling multiple actions.

    The Two Step View design pattern answers many of the issues presented. In this pattern, the "application" view is created first, and then injected into the "page" view, which is then presented to the client. The page view can be thought of as your site-wide template or layout, and would have common elements used across various pages.

    Within Zend Framework, Zend_Layout implements the Two Step View pattern.

    digg delicious meneame google twitter technorati facebook

    Comments

    Loading...