.. You may want to use the usual include line. Uncomment and adjust the path. .. include:: ../Includes.txt ================= EXT: My Extension ================= :Author: Kasper Skårhøj :Created: 2002-11-01T00:32:00 :Changed: 2009-02-19T21:58:11 :Author: Author Name :Email: your@email.com :Info 3: :Info 4: .. _ZView: ZView ===== Extension Key: **zview** Copyright, Zephir AG, Thomas Breuss, This document is published under the Open Content License available from http://www.opencontent.org/opl.shtml The content of this document is related to TYPO3 \- a GNU/GPL CMS/Framework available from www.typo3.com .. _Table-of-Contents: Table of Contents ----------------- **ZView 1** **Introduction 1** What does it do? 1 API Documentation 1 **Controller Script 1** **View Script 2** **Options 2** **View Helpers 3** Environment Helper 3 Image Helper 3 Link Helper 3 Mailto Helper 3 Page Helper 4 Popup Link Helper 4 Table Helper 4 Translate Helper 4 Url Helper 4 XmlEntities Helper 4 **Writing Custom Helpers 4** **Author 4** .. _Introduction: Introduction ------------ .. _What-does-it-do: What does it do? ^^^^^^^^^^^^^^^^ *ZView* is a class for working with the "view" portion of the model- view-controller pattern. It exists to help keep the view script separate from the model and controller scripts. It provides a system of helpers and variable escaping. *ZView* is something of an anti-templating engine in that it uses PHP natively for its templating. Using *ZView* happens in two major steps: Your controller script creates an instance of *ZView* and assigns variables to that instance. The controller tells the *ZView* to render a particular view, thereby handing control over the view script, which generates the view output. ZView extends Zend\_View\_Abstract. For more information about the Zend\_View component refer to their online manual. See `http://framework.zend.com/manual/en/zend.view.html `_ .. _API-Documentation: API Documentation ^^^^^^^^^^^^^^^^^ For the API documentation have a look at “doc/api/” within the ZV *iew* extension folder. .. _Controller-Script: Controller Script ----------------- The controller is where you instantiate and configure ZView. You then assign variables to the view, and tell the view to render output using a particular script. See `http://framework.zend.com/manual/en/zend.view.controllers.html `_ .. _generated: ((generated)) ^^^^^^^^^^^^^ .. _Example: Example """"""" As a simple example, your controller has a list of book data that it wants to have rendered by a view. The controller script might look something like this: :: 'J. K. Rowling', 'title' => 'Harry Potter and the Deathly Hallows' ), array( 'author' => 'Khaled Hosseini', 'title' => 'A Thousand Splendid Suns' ), array( 'author' => 'Milton Friedman', 'title' => 'Free to Choose' ), array( 'author' => 'Jeffrey Toobin', 'title' => 'The Nine: Inside the Secret World of the Supreme Court' ), array( 'author' => 'J. R. R. Tolkien', 'title' => 'The Children of Hurin' ) ); $view = t3lib_div::makeInstance('tx_zview'); $view->setPi($this); $view->addScriptPath('/path_to_view_scripts/'); $view->books = $books; $view->render('books.phtml'); .. _View-Script: View Script ----------- Once your controller has assigned variables and called render(), ZView then includes the requested view script and executes it "inside" the scope of the ZView instance. Therefore, in your view scripts, references to $this actually point to the ZView instance itself. See `http://framework.zend.com/manual/en/zend.view.scripts.html `_ .. _generated: ((generated)) ^^^^^^^^^^^^^ .. _Example: Example """"""" Now we need the associated view script called "books.phtml". A very basic view script could look like this: ::

Example 1: Using a foreach

books): ?> books as $key => $val): ?>
Title Author
escape($val['title']) ?> escape($val['author']) ?>

There are no books to display.

Please note: - The first line is used to prevent direct calls to the view script. - In the example above we use the "escape()" method to apply output escaping to variables. .. _Options: Options ------- Zview extends Zend\_View\_Abstract and has one additional option: *\_pi:* The base class for frontend plugins. May be set via setPi() See `http://framework.zend.com/manual/en/zend.view.html#zend.view.intr oduction.options `_ .. _View-Helpers: View Helpers ------------ In view scripts, often it is necessary to perform certain complex functions over and over: e.g., formatting a date, generating form elements, or displaying action links. You can use helper classes to perform these behaviors for you. See `http://framework.zend.com/manual/en/zend.view.helpers.html `_ Since version 0.2 of this extension all helpers are prefixed with “t3”. Examples: - $this->t3link() - $this->t3translate('Translate this') - $this->t3image('an-image.jpg', 200, 0) .. _Environment-Helper: Environment Helper ^^^^^^^^^^^^^^^^^^ Returns System Environment Variables regardless of server OS, CGI/MODULE version etc. Basically this is SERVER variables for most of them. This is a wrapper for t3lib\_div::getIndpEnv(); .. _Example: Example: """""""" :: t3env('TYPO3_REQUEST_HOST') ?> t3env('TYPO3_HOST_ONLY') ?> For more examples refer to the inline documentation of t3lib\_div::getIndpEnv(). .. _Image-Helper: Image Helper ^^^^^^^^^^^^ Generates a cached image element using the image manipulation class of TYPO3. .. _Examples: Examples: """"""""" :: t3image('typo3conf/ext/zviewtest/pi1/res/colors.jpg', 200, 0, 'jpg') ?> t3image('typo3conf/ext/zviewtest/pi1/res/colors.png', 150, 0, 'png') ?> t3image('typo3conf/ext/zviewtest/pi1/res/colors.gif', 100, 0, 'gif') ?> See example 7 of extension *zviewtest.* .. _Link-Helper: Link Helper ^^^^^^^^^^^ Generates a link using the tslib\_pibase methods of TYPO3. See example 5 of extension *zviewtest* . .. _t3link: t3link() """""""" Shortform of t3link()->thisPagePIvars(). .. _t3link-toPage: t3link()->toPage() """""""""""""""""" Generates a link to a certain page. .. _t3link-toPagePIvars: t3link()->toPagePIvars() """""""""""""""""""""""" Generates a link to a certain page using PI vars .. _t3link-thisPage: t3link()->thisPage() """""""""""""""""""" Generates a link to the this page (the caller page). .. _t3link-thisPagePIvars: t3link()->thisPagePIvars() """""""""""""""""""""""""" Generates a link to the current page (the caller page) using PI vars. .. _Mailto-Helper: Mailto Helper ^^^^^^^^^^^^^ Generates mailto link elements. .. _t3mailto: t3mailto() """""""""" Shortform of t3mailto()->link(). .. _t3mailto-link: t3mailto()->link() """""""""""""""""" Generates a mailto link. .. _t3mailto-href: t3mailto()->href() """""""""""""""""" Generates a mailto href for use in attribute href of an a-tag. See example 8 of extension *zviewtest* . .. _Page-Helper: Page Helper ^^^^^^^^^^^ Retrieves a field of TYPO3s page table. .. _t3page-string-key: t3page(string $key) """"""""""""""""""" Retrieve the field $key of the current page. Any fields of pages\_language\_overlay will be applied before the result is returned. .. _Popup-Link-Helper: Popup Link Helper ^^^^^^^^^^^^^^^^^ Generates a link to open a new popup window. .. _t3popup: t3popup() """"""""" Generates a popup link adding a js onclick (acts as a wrapper). .. _Table-Helper: Table Helper ^^^^^^^^^^^^ Generates a table element. See example 6 of extension *zviewtest* . .. _Translate-Helper: Translate Helper ^^^^^^^^^^^^^^^^ Translates a text string using the translation methods of TYPO3. If Zend\_Translate is instantiated and registered in Zend Registry using key “Zend\_Translate”, Zends translate adapter is used. See example 4 of extension *zviewtest* . .. _Url-Helper: Url Helper ^^^^^^^^^^ Generates an url using the tslib\_pibase methods of TYPO3. See example 5 of extension *zviewtest* . .. _t3url: t3url() """"""" Shortform of t3url()->thisPagePIvars(). .. _t3url-toPage: t3url()->toPage() """"""""""""""""" Generates an URL to a certain page. .. _t3url-toPagePIvars: t3url()->toPagePIvars() """"""""""""""""""""""" Generates an URL to a certain page using PI vars .. _t3url-thisPage: t3url()->thisPage() """"""""""""""""""" Generates an URL to the this page (the caller page). .. _t3url-thisPagePIvars: t3url()->thisPagePIvars() """"""""""""""""""""""""" Generates an URL to the current page (the caller page) using PI vars. .. _XmlEntities-Helper: XmlEntities Helper ^^^^^^^^^^^^^^^^^^ Generates a XML conform text string. .. _Writing-Custom-Helpers: Writing Custom Helpers ---------------------- See `http://framework.zend.com/manual/en/zend.view.helpers.html#zend.v iew.helpers.custom `_ .. _Author: Author ------ Thomas Breuss Zephir Software Design AG Tramstrasse 66 CH-4142 Münchenstein/Basel `http://www.zephir.ch `_ |img-1| ZView - 4 .. ######CUTTER_MARK_IMAGES###### .. |img-1| image:: img-1.png .. :align: left .. :border: 0 .. :height: 32 .. :id: Graphic1 .. :name: Graphic1 .. :width: 102