SlideShare a Scribd company logo
Zend_Layout & Zend_View Enhancements Ralph Schindler Software Engineer, Zend Technologies Zend Framework includes a powerful set of components that facilitate best practices in the area of keeping a consistent look and feel within an application.
Overview The problem Zend_Layout/ZVE solves Simple MVC Usage Benefits of Zend_Layout & ZVE Advanced Usage Case: local layouts within a module Q & A
THE PROBLEM Exploring the problem area
The Problem What are layouts? Consistent look and feel across application Independent of dispatched application code Common page items such as: Navigation Headers Footers Tag cloud
The Problem Previous attempts (PHP4 till now): Smarty (separation of business & presentation logic) First divergence from Model 1 programming. Common solution (included in every template): Header {include file=‘header.tpl’} Footer files {include file=‘footer.tpl’} Navigation {include file=‘common/nav.tpl’}  Ref:  http://en.wikipedia.org/wiki/Model_1
The Problem Previous attempts in ZF community: Controller Plugin dispatchLoopStartup() / preDispatch() dispatchLoopShutdown() / postDispatch() ViewRenderer Extension postDispatch() View Extension
The Problem Does a best practices pattern exist? Yes, in PoEAA, M. Fowler describes the Two-Step-View Pattern. “ Turns domain data into HTML in two steps: first by forming some kind of logical page, then rendering the logical page into HTML.”
The Problem Can ZF implement a Two-Step-View solution? Yes, if we leverage both the controller and the view layer, a two-step-view is possible. Lets look at the controller dispatch process: (image on next screen)
The Problem
The Problem Zend_Layout is the solution! Zend_Layout by itself is simply a view decorator When used in conjunction with the MVC elements its so much more: A Controller Plugin for detecting when to render a layout An Action Helper to facilitate communication between Action Controllers and Layouts A View Helper to facilitate communication between View Scripts and Layouts
The Problem The Two-Step-View and Zend_Layout introduce new concerns: How can view scripts know the content type of the current layout?  View Scripts might use code that implies a requirement at the layout layer: Setting page title Inject JS in the HEAD block Inject Style requirements in the HEAD block Etc.
The Problem With new problems, come new solutions! Zend View Enhancements Doctype helper for setting/getting content type Head Helpers: headScript() headMeta() headStyle() headTitle()
The Problem In addition to solving problems, there are a few other Zend_View Enhancements to simply life: Partial(), PartialLoop(), and Placeholder() exist to aid developers in DRYing up their code Action() View Helper exists to facilitate the dispatching of an Action Controller when a task requires that views attempt to gain new information from the model layer.
The Problem Zend_Layout and Zend_View Enhancements are the Solution! DRY up code Best Practices Better code organization both application and display logic Ability to add new features and requirements to a project without having to retrofit.
BASIC MVC USAGE Using Zend_Layout & Zend_View enhancements within a ZF MVC application
Basic MVC Usage File structure
Basic MVC Usage bootstrap.php
Basic MVC Usage Controller Script
Basic MVC Usage View Script
Basic MVC Usage Layout Script
Basic MVC Usage Output HTML & Display
Basic MVC Usage HeadTitle Usage
Basic MVC Usage Output HTML & View
Basic MVC Usage Partial & PartialLoop $this->partial($script, $model) $this->partialLoop($script, $arrayOfModels) Assumes “model” is An array Implements toArray Or is an object that can return properties via object_get_vars By passing a “model” as an object, and providing a key to access the properties
Basic MVC  Usage PartialLoop
BENEFITS Just a little review on the benefits
Benefits DRY up code (before and after)  Ability to scale and grow code without retrofiting
Benefits Zend_Layout & Zend_View enhancements are a supported best practice. Developers can find the code locations for improvements and fixes faster. Developers can get up to speed quicker with the detailed documentation and best practices these components promote.
ADVANCED USAGE Brief discussion of the advanced usage possibilities
Advanced Usage AJAX Support Pulling all the components together to make an Ajaxy Autocompleter headScript headStyle Dojo Toolkit ( http://www.dojotoolkit.org/  ) Zend_Layout
Advanced Usage The Model
Advanced Usage Controller
Advanced Usage View
Advanced Usage Layout
Advanced Usage
Advanced Usage JSON Output
Q&A TIME Stump the chump!  
CONFERENCE & DEMO Slides & Sample code will be provided following the confernece
RESOURCES Matthew W. O’Phinney’s Blog: http://weierophinney.net/matthew/archives/163-Using-Zend_View-Placeholders-to-Your-Advantage.html Zend_Layout & Zend_View Manual: http://framework.zend.com/manual/en/zend.layout.html http://framework.zend.com/manual/en/zend.view.html Mailing List & #zftalk
Thank You! http://framework.zend.com [email_address]

More Related Content

ODP
Joomla Day India 2009 Business Logic With The Mvc
PPTX
Angular 9
PPT
Getting Started with Zend Framework
PDF
AngularJS: Overview & Key Features
PPTX
Introduction To Model View Presenter
PPTX
Angular tutorial
PPTX
Model View Presenter (MVP) In Aspnet
PPTX
Angular 4 and TypeScript
Joomla Day India 2009 Business Logic With The Mvc
Angular 9
Getting Started with Zend Framework
AngularJS: Overview & Key Features
Introduction To Model View Presenter
Angular tutorial
Model View Presenter (MVP) In Aspnet
Angular 4 and TypeScript

What's hot (20)

PDF
android design pattern
PPTX
Angular 9 New features
PPT
Code Camp 06 Model View Presenter Architecture
PDF
Angular EE - Special Workshop by Nir Kaufman
PPT
Design pattern in android
PPT
Introduction to Zend Framework
PPTX
Angular4 getting started
PPTX
Model View Presenter presentation
PPTX
Adapter Design Pattern
PPTX
Angular interview questions
PDF
MVC Seminar Presantation
PPTX
Slide Presentation of MVP Pattern Concept
PPTX
Type of angular 2
PPTX
Angular js
PPTX
How do i implement command design pattern in the java programming course with...
PPT
Why MVC?
PDF
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
PDF
Clean architecture: Android
PPTX
MVVM - Model View ViewModel
PPTX
Developing web apps using Java and the Play framework
android design pattern
Angular 9 New features
Code Camp 06 Model View Presenter Architecture
Angular EE - Special Workshop by Nir Kaufman
Design pattern in android
Introduction to Zend Framework
Angular4 getting started
Model View Presenter presentation
Adapter Design Pattern
Angular interview questions
MVC Seminar Presantation
Slide Presentation of MVP Pattern Concept
Type of angular 2
Angular js
How do i implement command design pattern in the java programming course with...
Why MVC?
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
Clean architecture: Android
MVVM - Model View ViewModel
Developing web apps using Java and the Play framework
Ad

Similar to Zend_Layout & Zend_View Enhancements (20)

PPT
MVC Demystified: Essence of Ruby on Rails
PPT
MVC From Beginner to Advance in Indian Style by - Indiandotnet
PPT
2007 Zend Con Mvc
PPTX
Asp.Net MVC Intro
PPTX
PPT
Gk1051 001 j2-ee_arch_tt425v1.1
PDF
Murach: An introduction to web programming with ASP.NET Core MVC
PDF
Handlebars and Require.js
PPTX
Mvc in symfony
PDF
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
ODP
Web 2.0
PPT
PPT
TDD with ASP.NET MVC 1.0
PPTX
Eclipse 40 and Eclipse e4
PPT
Zend_Tool: Rapid Application Development with Zend Framework
PPT
Hnd201 Building Ibm Lotus Domino Applications With Ajax Plugins
PPTX
Eclipse e4 on Java Forum Stuttgart 2010
PPT
Developing Java Web Applications
ODP
Drupal Best Practices
PDF
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
MVC Demystified: Essence of Ruby on Rails
MVC From Beginner to Advance in Indian Style by - Indiandotnet
2007 Zend Con Mvc
Asp.Net MVC Intro
Gk1051 001 j2-ee_arch_tt425v1.1
Murach: An introduction to web programming with ASP.NET Core MVC
Handlebars and Require.js
Mvc in symfony
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
Web 2.0
TDD with ASP.NET MVC 1.0
Eclipse 40 and Eclipse e4
Zend_Tool: Rapid Application Development with Zend Framework
Hnd201 Building Ibm Lotus Domino Applications With Ajax Plugins
Eclipse e4 on Java Forum Stuttgart 2010
Developing Java Web Applications
Drupal Best Practices
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Ad

More from Ralph Schindler (11)

KEY
Zend Code in ZF 2.0
KEY
Zend Di in ZF 2.0
PDF
Zend Framework 1 + Doctrine 2
PDF
484 Days of PHP 5.3
PDF
Modeling best practices
PPT
What's New in ZF 1.10
KEY
Extending ZF & Extending With ZF
KEY
Extending Zend_Tool
PDF
Zend_Tool In ZF 1.8 Webinar
PPT
Zend Framework 1.8 Features Webinar
PDF
Software Engineering In PHP
Zend Code in ZF 2.0
Zend Di in ZF 2.0
Zend Framework 1 + Doctrine 2
484 Days of PHP 5.3
Modeling best practices
What's New in ZF 1.10
Extending ZF & Extending With ZF
Extending Zend_Tool
Zend_Tool In ZF 1.8 Webinar
Zend Framework 1.8 Features Webinar
Software Engineering In PHP

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Big Data Technologies - Introduction.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Empathic Computing: Creating Shared Understanding
PDF
KodekX | Application Modernization Development
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
Teaching material agriculture food technology
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Electronic commerce courselecture one. Pdf
cuic standard and advanced reporting.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Dropbox Q2 2025 Financial Results & Investor Presentation
Big Data Technologies - Introduction.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Empathic Computing: Creating Shared Understanding
KodekX | Application Modernization Development
Encapsulation_ Review paper, used for researhc scholars
Mobile App Security Testing_ A Comprehensive Guide.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Teaching material agriculture food technology
Programs and apps: productivity, graphics, security and other tools
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Review of recent advances in non-invasive hemoglobin estimation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Electronic commerce courselecture one. Pdf

Zend_Layout & Zend_View Enhancements

  • 1. Zend_Layout & Zend_View Enhancements Ralph Schindler Software Engineer, Zend Technologies Zend Framework includes a powerful set of components that facilitate best practices in the area of keeping a consistent look and feel within an application.
  • 2. Overview The problem Zend_Layout/ZVE solves Simple MVC Usage Benefits of Zend_Layout & ZVE Advanced Usage Case: local layouts within a module Q & A
  • 3. THE PROBLEM Exploring the problem area
  • 4. The Problem What are layouts? Consistent look and feel across application Independent of dispatched application code Common page items such as: Navigation Headers Footers Tag cloud
  • 5. The Problem Previous attempts (PHP4 till now): Smarty (separation of business & presentation logic) First divergence from Model 1 programming. Common solution (included in every template): Header {include file=‘header.tpl’} Footer files {include file=‘footer.tpl’} Navigation {include file=‘common/nav.tpl’} Ref: http://en.wikipedia.org/wiki/Model_1
  • 6. The Problem Previous attempts in ZF community: Controller Plugin dispatchLoopStartup() / preDispatch() dispatchLoopShutdown() / postDispatch() ViewRenderer Extension postDispatch() View Extension
  • 7. The Problem Does a best practices pattern exist? Yes, in PoEAA, M. Fowler describes the Two-Step-View Pattern. “ Turns domain data into HTML in two steps: first by forming some kind of logical page, then rendering the logical page into HTML.”
  • 8. The Problem Can ZF implement a Two-Step-View solution? Yes, if we leverage both the controller and the view layer, a two-step-view is possible. Lets look at the controller dispatch process: (image on next screen)
  • 10. The Problem Zend_Layout is the solution! Zend_Layout by itself is simply a view decorator When used in conjunction with the MVC elements its so much more: A Controller Plugin for detecting when to render a layout An Action Helper to facilitate communication between Action Controllers and Layouts A View Helper to facilitate communication between View Scripts and Layouts
  • 11. The Problem The Two-Step-View and Zend_Layout introduce new concerns: How can view scripts know the content type of the current layout? View Scripts might use code that implies a requirement at the layout layer: Setting page title Inject JS in the HEAD block Inject Style requirements in the HEAD block Etc.
  • 12. The Problem With new problems, come new solutions! Zend View Enhancements Doctype helper for setting/getting content type Head Helpers: headScript() headMeta() headStyle() headTitle()
  • 13. The Problem In addition to solving problems, there are a few other Zend_View Enhancements to simply life: Partial(), PartialLoop(), and Placeholder() exist to aid developers in DRYing up their code Action() View Helper exists to facilitate the dispatching of an Action Controller when a task requires that views attempt to gain new information from the model layer.
  • 14. The Problem Zend_Layout and Zend_View Enhancements are the Solution! DRY up code Best Practices Better code organization both application and display logic Ability to add new features and requirements to a project without having to retrofit.
  • 15. BASIC MVC USAGE Using Zend_Layout & Zend_View enhancements within a ZF MVC application
  • 16. Basic MVC Usage File structure
  • 17. Basic MVC Usage bootstrap.php
  • 18. Basic MVC Usage Controller Script
  • 19. Basic MVC Usage View Script
  • 20. Basic MVC Usage Layout Script
  • 21. Basic MVC Usage Output HTML & Display
  • 22. Basic MVC Usage HeadTitle Usage
  • 23. Basic MVC Usage Output HTML & View
  • 24. Basic MVC Usage Partial & PartialLoop $this->partial($script, $model) $this->partialLoop($script, $arrayOfModels) Assumes “model” is An array Implements toArray Or is an object that can return properties via object_get_vars By passing a “model” as an object, and providing a key to access the properties
  • 25. Basic MVC Usage PartialLoop
  • 26. BENEFITS Just a little review on the benefits
  • 27. Benefits DRY up code (before and after) Ability to scale and grow code without retrofiting
  • 28. Benefits Zend_Layout & Zend_View enhancements are a supported best practice. Developers can find the code locations for improvements and fixes faster. Developers can get up to speed quicker with the detailed documentation and best practices these components promote.
  • 29. ADVANCED USAGE Brief discussion of the advanced usage possibilities
  • 30. Advanced Usage AJAX Support Pulling all the components together to make an Ajaxy Autocompleter headScript headStyle Dojo Toolkit ( http://www.dojotoolkit.org/ ) Zend_Layout
  • 37. Q&A TIME Stump the chump! 
  • 38. CONFERENCE & DEMO Slides & Sample code will be provided following the confernece
  • 39. RESOURCES Matthew W. O’Phinney’s Blog: http://weierophinney.net/matthew/archives/163-Using-Zend_View-Placeholders-to-Your-Advantage.html Zend_Layout & Zend_View Manual: http://framework.zend.com/manual/en/zend.layout.html http://framework.zend.com/manual/en/zend.view.html Mailing List & #zftalk