Zend_Layout & Zend_View Enhancements Ralph Schindler Software Engineer, Zend Technologies Zend Framework includes a powerf...
Overview <ul><li>The problem Zend_Layout/ZVE solves </li></ul><ul><li>Simple MVC Usage </li></ul><ul><li>Benefits of Zend_...
THE PROBLEM <ul><li>Exploring the problem area </li></ul>
The Problem <ul><li>What are layouts? </li></ul><ul><li>Consistent look and feel across application </li></ul><ul><li>Inde...
The Problem <ul><li>Previous attempts (PHP4 till now): </li></ul><ul><li>Smarty (separation of business & presentation log...
The Problem <ul><li>Previous attempts in ZF community: </li></ul><ul><li>Controller Plugin </li></ul><ul><ul><li>dispatchL...
The Problem <ul><li>Does a best practices pattern exist? </li></ul><ul><li>Yes, in PoEAA, M. Fowler describes the Two-Step...
The Problem <ul><li>Can ZF implement a Two-Step-View solution? </li></ul><ul><li>Yes, if we leverage both the controller a...
The Problem
The Problem <ul><li>Zend_Layout is the solution! </li></ul><ul><li>Zend_Layout by itself is simply a view decorator </li><...
The Problem <ul><li>The Two-Step-View and Zend_Layout introduce new concerns: </li></ul><ul><li>How can view scripts know ...
The Problem <ul><li>With new problems, come new solutions! </li></ul><ul><li>Zend View Enhancements </li></ul><ul><ul><li>...
The Problem <ul><li>In addition to solving problems, there are a few other Zend_View Enhancements to simply life: </li></u...
The Problem <ul><li>Zend_Layout and Zend_View Enhancements are the Solution! </li></ul><ul><li>DRY up code </li></ul><ul><...
BASIC MVC USAGE <ul><li>Using Zend_Layout & Zend_View enhancements within a ZF MVC application </li></ul>
Basic MVC Usage <ul><li>File structure </li></ul>
Basic MVC Usage <ul><li>bootstrap.php </li></ul>
Basic MVC Usage <ul><li>Controller Script </li></ul>
Basic MVC Usage <ul><li>View Script </li></ul>
Basic MVC Usage <ul><li>Layout Script </li></ul>
Basic MVC Usage <ul><li>Output HTML & Display </li></ul>
Basic MVC Usage <ul><li>HeadTitle Usage </li></ul>
Basic MVC Usage <ul><li>Output HTML & View </li></ul>
Basic MVC Usage <ul><li>Partial & PartialLoop </li></ul><ul><li>$this->partial($script, $model) </li></ul><ul><li>$this->p...
Basic MVC  Usage <ul><li>PartialLoop </li></ul>
BENEFITS <ul><li>Just a little review on the benefits </li></ul>
Benefits <ul><li>DRY up code (before and after)  </li></ul><ul><li>Ability to scale and grow code without retrofiting </li...
Benefits <ul><li>Zend_Layout & Zend_View enhancements are a supported best practice. </li></ul><ul><li>Developers can find...
ADVANCED USAGE <ul><li>Brief discussion of the advanced usage possibilities </li></ul>
Advanced Usage <ul><li>AJAX Support </li></ul><ul><li>Pulling all the components together to make an Ajaxy Autocompleter <...
Advanced Usage <ul><li>The Model </li></ul>
Advanced Usage <ul><li>Controller </li></ul>
Advanced Usage <ul><li>View </li></ul>
Advanced Usage <ul><li>Layout </li></ul>
Advanced Usage
Advanced Usage <ul><li>JSON Output </li></ul>
Q&A TIME <ul><li>Stump the chump!   </li></ul>
CONFERENCE & DEMO <ul><li>Slides & Sample code will be provided following the confernece </li></ul>
RESOURCES <ul><li>Matthew W. O’Phinney’s Blog: </li></ul><ul><li>http://weierophinney.net/matthew/archives/163-Using-Zend_...
Thank You! http://framework.zend.com [email_address]
Upcoming SlideShare
Loading in...5
×

Zend_Layout & Zend_View Enhancements

3,050

Published on

Published in: Technology
1 Comment
3 Likes
Statistics
Notes
No Downloads
Views
Total Views
3,050
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
158
Comments
1
Likes
3
Embeds 0
No embeds

No notes for slide
  • Zend_Layout & Zend_View Enhancements

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

      Clipping is a handy way to collect important slides you want to go back to later.

    ×