Skip to end of metadata
Go to start of metadata

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

Zend Framework: Zend_View_PhpTal Component Proposal

Proposed Component Name Zend_View_PhpTal
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Zend_View_PhpTal
Proposers Matthew Ratzloff
Revision 0.2 - September 12, 2007 (wiki revision: 15)

Table of Contents

1. Overview

Zend_View_PhpTal is an implementation of Zend_View_Interface for the PHPTAL templating engine.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

Handle calls to the PHPTAL engine as transparently as possible for basic operations.

4. Dependencies on Other Framework Components

  • Zend_View_Interface
  • PHPTAL

5. Theory of Operation

Implement basic functionality while letting calls to getEngine() handle more advanced concepts (macros, etc.).

6. Milestones / Tasks

  • Milestone 1: [DONE] This proposal
  • Milestone 2: [DONE] Working implementation
  • Milestone 3: Unit tests exist, work, and are checked in.
  • Milestone 4: Documentation

7. Class Index

  • Zend_View_PhpTal

8. Use Cases

Works like Zend_View. Additional functionality is self-explanatory. See full code below.

9. Class Skeletons

]]></ac:plain-text-body></ac:macro>

]]></ac:plain-text-body></ac:macro>

Labels:
zend_view_interface zend_view_interface Delete
zend_view_phptal zend_view_phptal Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Dec 08, 2006

    <p>Matt – when you document this, and also in the class-level docblock, please put a notice that phptal is licensed under the LGPL and that users should only use the wrapper and phptal when their project license will not conflict with the LGPL.</p>

    <p>Otherwise, looks good!</p>

  2. Jan 31, 2008

    <p>Matt,</p>

    <p>First of all thank you for your work on this class, I was thinking about implementing it when I found it <ac:emoticon ac:name="smile" /></p>

    <p>What would you thing of changing __get() to the following:</p>

    <ac:macro ac:name="noformat"><ac:plain-text-body><![CDATA[
    if ($this->__isset($key)) {
    if (is_array($this->_variables[$key]))

    Unknown macro: { return new ArrayObject($this->_variables[$key]); }

    return $this->_variables[$key];
    }
    return null;
    ]]></ac:plain-text-body></ac:macro>

    <p>This change (returning an ArrayObject for array variables) allows to have read-write access on the variable when accessing it from the view object. Like in the following example:</p>

    <ac:macro ac:name="noformat"><ac:plain-text-body><![CDATA[
    $this->view->errors = array();
    $this->view->errors[] = 'First error';
    $this->view->errors[] = 'Second error';
    ]]></ac:plain-text-body></ac:macro>

    <p>I guess it's not the fastest code but it's quite convenient.</p>

    <p>Besides, setting a variable starting with an underscore ('_') just silently ignores the action. I think it should throw an exception to notify the developer. Moreover, the assign() method does not even check for the underscore which could result on a exception being thrown from Phptal at render time, since the variables are actually passed over then.</p>

    <p>Just a last thing. Why are the script paths using 'templates' as the default folder name instead of 'scripts'? Is it intended or just a left over from previous ZF versions?</p>

    <p>cheers,<br />
    Iván</p>

    1. Feb 02, 2008

      <p>Hi Iván,</p>

      <p>Most of those methods were copied and modified from Zend_View_Abstract as it existed at the time this was originally written. If this proposal were to be resurrected it would be updated to match whatever Zend_View looks like currently.</p>

      <p>As far as the "templates" name, that was specific to my use at the time and I forgot to update it. <ac:emoticon ac:name="smile" /></p>

  3. May 10, 2009

    <p>Is this proposal dead? I hope not! I'm looking forward to see such a component..</p>

  4. Jun 14, 2009

    <p>I have modified Your code to extend Zend_View_Abstract. Unfortunately there is no english version in this moment so You have to use translator (comments are in English, I'll try to rewrite it soon).</p>

    <p><a href="http://translate.google.pl/translate?prev=hp&hl=pl&js=n&u=http%3A%2F%2Ftworzenie-stron-www.org%2Fstrony-www%2Fartykuly%2F7%2Fsystem_szablonow_phptal_jako_widok_w_zend_framework&sl=pl&tl=en&history_state0=&swap=1">PHPTAL View (Zend_View_Abstract)</a></p>

    <p>Gtranslate has some problems with valid syntax so please refer to original text.<br />
    Article contains examples both with Zend_Application and standard aproach. Additionaly `helper:` modifier is available inside templates (e.g. <a tal:attributes="href helper:url(array('username' => 'martel'), 'user'))">Martel</a>), templates could be gzipped and correct headers are set (because ZF does not have any Zend_Client class i put my own My_Browser class).</p>