<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Zend Framework View Helpers</title>
	<atom:link href="http://www.potstuck.com/2009/05/11/zend-framework-view-helpers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.potstuck.com/2009/05/11/zend-framework-view-helpers/</link>
	<description></description>
	<lastBuildDate>Fri, 23 Dec 2011 14:29:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Ian Warner</title>
		<link>http://www.potstuck.com/2009/05/11/zend-framework-view-helpers/comment-page-1/#comment-91</link>
		<dc:creator>Ian Warner</dc:creator>
		<pubDate>Thu, 10 Sep 2009 15:17:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.potstuck.com/?p=113#comment-91</guid>
		<description>Ryan

Lol just encountered that today when I had doubled up on a helper

In hindsight then is this the best method, calling many methods each time must have a overhead?? : I was doing this before:

Setting the properties as a default:

    // {{{ properties

    /**
     * Vars to set the defaults for the request invite forms
     */
    private $defaults = array(
      &#039;canPost&#039;      =&gt; true,
      &#039;canDelete&#039;    =&gt; false,
      &#039;canMark&#039;      =&gt; true,
      &#039;canCreate&#039;    =&gt; true,
      &#039;numberTopics&#039; =&gt; 5,
      &#039;callbackUrl&#039;  =&gt; false,
      &#039;returnUrl&#039;    =&gt; false
     );

    // }}}

in the helper method:

public function facebook_Board($params = array()) {

        // Merge the two arrays to overwrite default values.
        $params = array_merge($this-&gt;defaults, $params);

echo $params[&#039;canPost&#039;];

}

This way I could set an array at the helper load that was nicely key paired.</description>
		<content:encoded><![CDATA[<p>Ryan</p>
<p>Lol just encountered that today when I had doubled up on a helper</p>
<p>In hindsight then is this the best method, calling many methods each time must have a overhead?? : I was doing this before:</p>
<p>Setting the properties as a default:</p>
<p>    // {{{ properties</p>
<p>    /**<br />
     * Vars to set the defaults for the request invite forms<br />
     */<br />
    private $defaults = array(<br />
      &#8216;canPost&#8217;      =&gt; true,<br />
      &#8216;canDelete&#8217;    =&gt; false,<br />
      &#8216;canMark&#8217;      =&gt; true,<br />
      &#8216;canCreate&#8217;    =&gt; true,<br />
      &#8216;numberTopics&#8217; =&gt; 5,<br />
      &#8216;callbackUrl&#8217;  =&gt; false,<br />
      &#8216;returnUrl&#8217;    =&gt; false<br />
     );</p>
<p>    // }}}</p>
<p>in the helper method:</p>
<p>public function facebook_Board($params = array()) {</p>
<p>        // Merge the two arrays to overwrite default values.<br />
        $params = array_merge($this-&gt;defaults, $params);</p>
<p>echo $params['canPost'];</p>
<p>}</p>
<p>This way I could set an array at the helper load that was nicely key paired.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://www.potstuck.com/2009/05/11/zend-framework-view-helpers/comment-page-1/#comment-90</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Thu, 27 Aug 2009 09:07:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.potstuck.com/?p=113#comment-90</guid>
		<description>Ryan,

What do you think about view helpers that throw exceptions? I like the idea of using the __toString() method, but this will result in an error if an exception is thrown.

Thanks.</description>
		<content:encoded><![CDATA[<p>Ryan,</p>
<p>What do you think about view helpers that throw exceptions? I like the idea of using the __toString() method, but this will result in an error if an exception is thrown.</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://www.potstuck.com/2009/05/11/zend-framework-view-helpers/comment-page-1/#comment-86</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Wed, 19 Aug 2009 06:29:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.potstuck.com/?p=113#comment-86</guid>
		<description>hey ian, 

the reason i use a default values method is because the zend framework will keep the same instance of the view helper for later use.  we need to &#039;reset&#039; the instance every time we call the helper.  if we do not, this would happen:

$this-&gt;friends()-&gt;show(3)-&gt;gender(&#039;Male&#039;)

we would expect it to output 3 male friends.


now, later on the page, we call $this-&gt;friends()-&gt;show(5) and expect it to output 5 friends, male or female.  however, since we used -&gt;gender(&#039;Male&#039;) earlier, it will only output male friends.


the _defaultValues() method should reset all parameters to their default state to prevent this confusion.

thanks for the comments.</description>
		<content:encoded><![CDATA[<p>hey ian, </p>
<p>the reason i use a default values method is because the zend framework will keep the same instance of the view helper for later use.  we need to &#8216;reset&#8217; the instance every time we call the helper.  if we do not, this would happen:</p>
<p>$this->friends()->show(3)->gender(&#8216;Male&#8217;)</p>
<p>we would expect it to output 3 male friends.</p>
<p>now, later on the page, we call $this->friends()->show(5) and expect it to output 5 friends, male or female.  however, since we used ->gender(&#8216;Male&#8217;) earlier, it will only output male friends.</p>
<p>the _defaultValues() method should reset all parameters to their default state to prevent this confusion.</p>
<p>thanks for the comments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Warenr</title>
		<link>http://www.potstuck.com/2009/05/11/zend-framework-view-helpers/comment-page-1/#comment-85</link>
		<dc:creator>Ian Warenr</dc:creator>
		<pubDate>Mon, 17 Aug 2009 23:18:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.potstuck.com/?p=113#comment-85</guid>
		<description>Hi

Where do the properties

_show and _gender come into play

dont you want

#  private $show = DefaultValue;  
#  private $gender = DefaultValue;

you can then get rid of the other method that sets the defaults.

You should put the toString into the final method.

Good stuff</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>Where do the properties</p>
<p>_show and _gender come into play</p>
<p>dont you want</p>
<p>#  private $show = DefaultValue;<br />
#  private $gender = DefaultValue;</p>
<p>you can then get rid of the other method that sets the defaults.</p>
<p>You should put the toString into the final method.</p>
<p>Good stuff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NickG</title>
		<link>http://www.potstuck.com/2009/05/11/zend-framework-view-helpers/comment-page-1/#comment-74</link>
		<dc:creator>NickG</dc:creator>
		<pubDate>Thu, 14 May 2009 10:15:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.potstuck.com/?p=113#comment-74</guid>
		<description>Good Stuff :)

Do you think it would be helpful to add something like;

    public function __call($method, $args)
    {
        App::log(&quot;ERROR: No method &#039;$method&#039; in helper &quot;.get_class($this));
        return $this;
    }

to prevent any possible &quot;Call to undefined method&quot; errors?</description>
		<content:encoded><![CDATA[<p>Good Stuff <img src='http://www.potstuck.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Do you think it would be helpful to add something like;</p>
<p>    public function __call($method, $args)<br />
    {<br />
        App::log(&#8220;ERROR: No method &#8216;$method&#8217; in helper &#8220;.get_class($this));<br />
        return $this;<br />
    }</p>
<p>to prevent any possible &#8220;Call to undefined method&#8221; errors?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Federico</title>
		<link>http://www.potstuck.com/2009/05/11/zend-framework-view-helpers/comment-page-1/#comment-72</link>
		<dc:creator>Federico</dc:creator>
		<pubDate>Wed, 13 May 2009 22:25:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.potstuck.com/?p=113#comment-72</guid>
		<description>Nice post, thanks.</description>
		<content:encoded><![CDATA[<p>Nice post, thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced

Served from: www.potstuck.com @ 2012-02-05 15:02:26 -->
