<?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: An idea for loading helpers in the view</title>
	<atom:link href="http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 31 Jan 2012 15:12:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/comment-page-1/#comment-192129</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 22 Feb 2011 16:43:17 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=724#comment-192129</guid>
		<description>@mark: Thanks for your comment!

Well, unless the plans have changed Cake2 is targeted for PHP 5.2.x (see the &lt;a href=&quot;http://bakery.cakephp.org/articles/markstory/2010/12/26/happy_holiday_yule_cake_-_cakephp_2_0-dev_released&quot; rel=&quot;nofollow&quot;&gt;announcement&lt;/a&gt; of cake2-dev). While it will work on PHP 5.3, it can&#039;t use any of the new features available in PHP 5.3...  

And this leads to the same &quot;problem&quot; we have today with CakePHP&#039;s PHP4-compatibility: it limits the possibilities of what the framework devs can accomplish. I don&#039;t know how often I wished the devs would have used PHP5 features like interfaces and abstract classes. It would have made my life much easier. And I think the same is true for PHP 5.3: you will wish the framework devs would have used some of its features.

I hope this explains what the problem is ;-)</description>
		<content:encoded><![CDATA[<p>@mark: Thanks for your comment!</p>
<p>Well, unless the plans have changed Cake2 is targeted for PHP 5.2.x (see the <a href="http://bakery.cakephp.org/articles/markstory/2010/12/26/happy_holiday_yule_cake_-_cakephp_2_0-dev_released" rel="nofollow">announcement</a> of cake2-dev). While it will work on PHP 5.3, it can&#8217;t use any of the new features available in PHP 5.3&#8230;  </p>
<p>And this leads to the same &#8220;problem&#8221; we have today with CakePHP&#8217;s PHP4-compatibility: it limits the possibilities of what the framework devs can accomplish. I don&#8217;t know how often I wished the devs would have used PHP5 features like interfaces and abstract classes. It would have made my life much easier. And I think the same is true for PHP 5.3: you will wish the framework devs would have used some of its features.</p>
<p>I hope this explains what the problem is ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mark</title>
		<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/comment-page-1/#comment-191984</link>
		<dc:creator>mark</dc:creator>
		<pubDate>Mon, 21 Feb 2011 23:14:35 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=724#comment-191984</guid>
		<description>well, cake2 is just around the corner
including php5.3 ;) so, whats the problem?^^</description>
		<content:encoded><![CDATA[<p>well, cake2 is just around the corner<br />
including php5.3 ;) so, whats the problem?^^</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/comment-page-1/#comment-191918</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Mon, 21 Feb 2011 16:21:23 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=724#comment-191918</guid>
		<description>@keymaster: Thanks for your comment!

Well, I probably have to disappoint you... I&#039;m no longer using CakePHP very often, so there isn&#039;t much to write about. Plus CakePHP feels &quot;dated&quot; to me with no PHP5.3 version on the horizon...

Anyway, I hope to get back to blog more regularly, I have become too lazy on the blogging front ;-)</description>
		<content:encoded><![CDATA[<p>@keymaster: Thanks for your comment!</p>
<p>Well, I probably have to disappoint you&#8230; I&#8217;m no longer using CakePHP very often, so there isn&#8217;t much to write about. Plus CakePHP feels &#8220;dated&#8221; to me with no PHP5.3 version on the horizon&#8230;</p>
<p>Anyway, I hope to get back to blog more regularly, I have become too lazy on the blogging front ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keymaster</title>
		<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/comment-page-1/#comment-191715</link>
		<dc:creator>keymaster</dc:creator>
		<pubDate>Sun, 20 Feb 2011 17:11:30 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=724#comment-191715</guid>
		<description>CakeBaker,

Just read this post, almost 2.5 years after you wrote it, and it is still totally relevant and forward thinking.

Hopefully soon you&#039;ll consider blogging again on a regular basis about cakephp.

All the best.</description>
		<content:encoded><![CDATA[<p>CakeBaker,</p>
<p>Just read this post, almost 2.5 years after you wrote it, and it is still totally relevant and forward thinking.</p>
<p>Hopefully soon you&#8217;ll consider blogging again on a regular basis about cakephp.</p>
<p>All the best.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/comment-page-1/#comment-164797</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 10 Jun 2010 14:33:06 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=724#comment-164797</guid>
		<description>@mark: Thanks for your comment!

According to &lt;a href=&quot;http://cakephp.lighthouseapp.com/projects/42648/2-0-development-roadmap&quot; rel=&quot;nofollow&quot;&gt;CakePHP&#039;s roadmap&lt;/a&gt; lazy loading of helpers (and models &amp; components) is planned for CakePHP 2.0, though I don&#039;t know how they intend to implement it.</description>
		<content:encoded><![CDATA[<p>@mark: Thanks for your comment!</p>
<p>According to <a href="http://cakephp.lighthouseapp.com/projects/42648/2-0-development-roadmap" rel="nofollow">CakePHP&#8217;s roadmap</a> lazy loading of helpers (and models &#038; components) is planned for CakePHP 2.0, though I don&#8217;t know how they intend to implement it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mark</title>
		<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/comment-page-1/#comment-164627</link>
		<dc:creator>mark</dc:creator>
		<pubDate>Tue, 08 Jun 2010 18:42:14 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=724#comment-164627</guid>
		<description>an old discussion - but somewhat still a hot topic these days.
especially as the helpers are now properly attached to the view class.
$this-&gt;Helper-&gt;method() is now the default way to use helpers (in cake1.3)

so did someone already open a ticket for this nice and clean idea to load helpers where they are needed (lazy) instead of loading them far away in the controller methods?

for backwords comp. you could just &quot;enhance&quot; the current view - loading all controller helpers + the ability to load the rest via 
$this-&gt;loadHelpers(&#039;MyHelper&#039;);
and
$this-&gt;loadHelpers(array(&#039;MyHelper&#039;, ...));

currently loadHelpers() does not seem to be used in that way.</description>
		<content:encoded><![CDATA[<p>an old discussion &#8211; but somewhat still a hot topic these days.<br />
especially as the helpers are now properly attached to the view class.<br />
$this-&gt;Helper-&gt;method() is now the default way to use helpers (in cake1.3)</p>
<p>so did someone already open a ticket for this nice and clean idea to load helpers where they are needed (lazy) instead of loading them far away in the controller methods?</p>
<p>for backwords comp. you could just &#8220;enhance&#8221; the current view &#8211; loading all controller helpers + the ability to load the rest via<br />
$this-&gt;loadHelpers(&#8216;MyHelper&#8217;);<br />
and<br />
$this-&gt;loadHelpers(array(&#8216;MyHelper&#8217;, &#8230;));</p>
<p>currently loadHelpers() does not seem to be used in that way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/comment-page-1/#comment-133923</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Sun, 02 Aug 2009 15:42:24 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=724#comment-133923</guid>
		<description>@leo: Thanks for your comment!

Yes, you can do it in that way and it is probably a better solution than what I have shown (though in View::_loadHelpers(), called by loadHelpers(), there is also a check to prevent loading the same helper twice).</description>
		<content:encoded><![CDATA[<p>@leo: Thanks for your comment!</p>
<p>Yes, you can do it in that way and it is probably a better solution than what I have shown (though in View::_loadHelpers(), called by loadHelpers(), there is also a check to prevent loading the same helper twice).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: leo</title>
		<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/comment-page-1/#comment-133801</link>
		<dc:creator>leo</dc:creator>
		<pubDate>Fri, 31 Jul 2009 15:13:03 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=724#comment-133801</guid>
		<description>Sorry to revive an old conversation, but wouldn&#039;t it be better if the __get method checked if the property was there, and only loaded the helpers if it wasn&#039;t found? Seems something like:

&lt;code&gt;
function get__($property) {
     if(!property_exists($this, $property)) {
        $this-&gt;loadHelpers(array($property));
     }
     return $this-&gt;{$property};
}
&lt;/code&gt;

would be slightly better, no? I&#039;m a little bit new at PHP OOP, so forgive me if I&#039;m wrong.</description>
		<content:encoded><![CDATA[<p>Sorry to revive an old conversation, but wouldn&#8217;t it be better if the __get method checked if the property was there, and only loaded the helpers if it wasn&#8217;t found? Seems something like:</p>
<pre><code>function get__($property) {
     if(!property_exists($this, $property)) {
        $this-&gt;loadHelpers(array($property));
     }
     return $this-&gt;{$property};
}</code></pre>
<p>would be slightly better, no? I&#8217;m a little bit new at PHP OOP, so forgive me if I&#8217;m wrong.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/comment-page-1/#comment-110878</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 21 Oct 2008 16:27:50 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=724#comment-110878</guid>
		<description>@nao: In the loadHelpers() method you have to add the following statement:
&lt;code&gt;
$this-&gt;helpers = $helperNames;
&lt;/code&gt;
And then you have to override the _render() method (I&#039;m not sure whether this works 100%):
&lt;code&gt;
public function _render($___viewFn, $___dataForView, $loadHelpers = true, $cached = false) {
    parent::_render($___viewFn, $___dataForView, $loadHelpers, $cached);
    foreach ($this-&gt;helpers as $helper) {
        $this-&gt;{$helper}-&gt;afterRender();
    }
}
&lt;/code&gt;
Hope it helps!</description>
		<content:encoded><![CDATA[<p>@nao: In the loadHelpers() method you have to add the following statement:<br />
<code>$this-&gt;helpers = $helperNames;</code><br />
And then you have to override the _render() method (I&#8217;m not sure whether this works 100%):<br />
<pre><code>public function _render($___viewFn, $___dataForView, $loadHelpers = true, $cached = false) {
    parent::_render($___viewFn, $___dataForView, $loadHelpers, $cached);
    foreach ($this-&gt;helpers as $helper) {
        $this-&gt;{$helper}-&gt;afterRender();
    }
}</code></pre><br />
Hope it helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nao</title>
		<link>http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/comment-page-1/#comment-110647</link>
		<dc:creator>nao</dc:creator>
		<pubDate>Sun, 19 Oct 2008 09:40:34 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=724#comment-110647</guid>
		<description>Hi,

Someone find solution for afterRender() calling when loading helpers in the view ?</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Someone find solution for afterRender() calling when loading helpers in the view ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

