Quick Upload

Loading...
Flash Player 9 (or above) is needed to view slideshows. We have detected that you do not have it on your computer.To install it, go here
Post to Twitter Post to Twitter
Share on Facebook
Myspace Hi5 Friendster Xanga LiveJournal Facebook Blogger Tagged Typepad Freewebs BlackPlanet gigya icons
« Prev Comments 0 - 0 of 0 Next »
    Add a comment If you have a SlideShare account, login to comment; otherwise comment as a guest.
    • In the design of Java Web applications, there are two commonly-used design models, referred to as Model 1 and Model 2.In Model 1, a request is made to a JSP or servlet and then that JSP or servlet handles all responsibilities for the request, including processing the request, validating data, handling the business logic, and generating a response.
    • The Partial view helper is used to render a specified template within its own variable scope. The primary use is for reusable template fragments with which you do not need to worry about variable name clashes. Additionally, they allow you to specify partial view scripts from specific modules.
    SlideShare is now available on LinkedIn. Add it to your LinkedIn profile.

    Zend_Layout & Zend_View Enhancements

    From ralphschindler, 2 months ago Add as contact

    324 views | 0 comments | 1 favorites | 21 downloads | 0 embeds (Stats)

    Embed in your blog options close
    Embed (wordpress.com) Exclude related slideshows Embed in your blog

    More Info

    This slideshow is Public
    Total Views: 324 on Slideshare: 324 from embeds: 0
    Flagged as inappropriate Flag as inappropriate

    Flag as inappropriate

    Select your reason for flagging this slideshow as inappropriate.

    If needed, use the feedback form to let us know more details.

    Slideshow Transcript

    1. Slide 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. Copyright © 2008, Zend Technologies Inc.
    2. Slide 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. Slide 3: Exploring the problem area THE PROBLEM
    4. Slide 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. Slide 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. Slide 6: The Problem Previous attempts in ZF community: • Controller Plugin • dispatchLoopStartup() / preDispatch() • dispatchLoopShutdown() / postDispatch() • ViewRenderer Extension • postDispatch() • View Extension
    7. Slide 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. Slide 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)
    9. Slide 9: The Problem
    10. Slide 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. Slide 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. Slide 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. Slide 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. Slide 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. Slide 15: Using Zend_Layout & Zend_View enhancements within a ZF MVC application BASIC MVC USAGE
    16. Slide 16: Basic MVC Usage File structure
    17. Slide 17: Basic MVC Usage bootstrap.php
    18. Slide 18: Basic MVC Usage Controller Script
    19. Slide 19: Basic MVC Usage View Script
    20. Slide 20: Basic MVC Usage • Layout Script
    21. Slide 21: Basic MVC Usage • Output HTML & Display
    22. Slide 22: Basic MVC Usage • HeadTitle Usage
    23. Slide 23: Basic MVC Usage Output HTML & View
    24. Slide 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. Slide 25: Basic MVC Usage • PartialLoop
    26. Slide 26: Just a little review on the benefits BENEFITS
    27. Slide 27: Benefits • DRY up code (before and after) • Ability to scale and grow code without retrofiting
    28. Slide 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. Slide 29: Brief discussion of the advanced usage possibilities ADVANCED USAGE
    30. Slide 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
    31. Slide 31: Advanced Usage The Model
    32. Slide 32: Advanced Usage Controller
    33. Slide 33: Advanced Usage View
    34. Slide 34: Advanced Usage Layout
    35. Slide 35: Advanced Usage
    36. Slide 36: Advanced Usage • JSON Output
    37. Slide 37: Stump the chump!  Q&A TIME
    38. Slide 38: Slides & Sample code will be provided following the confernece CONFERENCE & DEMO
    39. Slide 39: Matthew W. O’Phinney’s Blog: http://weierophinney.net/matthew/archives/163-Using-Zend_View-Plac 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 RESOURCES
    40. Slide 40: Thank You! http://framework.zend.com ralph.schindler@zend.com Copyright © 2008, Zend Technologies Inc.