<?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 alternative to requestAction</title>
	<atom:link href="http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Wed, 28 Jul 2010 19:06:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/comment-page-1/#comment-104035</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Fri, 22 Aug 2008 16:12:15 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=717#comment-104035</guid>
		<description>@Rafael: I think teknoid&#039;s approach is an interesting proof of concept, but personally I wouldn&#039;t use it. It is, as you say, not very simple...

Yes, setting the helpers in the beforeRender() method would be a more logical alternative. But in principle I think the definition of the helpers should happen where the helpers are actually used, see also my &lt;a href=&quot;http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/&quot; rel=&quot;nofollow&quot;&gt;latest article&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>@Rafael: I think teknoid&#8217;s approach is an interesting proof of concept, but personally I wouldn&#8217;t use it. It is, as you say, not very simple&#8230;</p>
<p>Yes, setting the helpers in the beforeRender() method would be a more logical alternative. But in principle I think the definition of the helpers should happen where the helpers are actually used, see also my <a href="http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/" rel="nofollow">latest article</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: An idea for loading helpers in the view - cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/comment-page-1/#comment-104026</link>
		<dc:creator>An idea for loading helpers in the view - cakebaker</dc:creator>
		<pubDate>Fri, 22 Aug 2008 15:20:25 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=717#comment-104026</guid>
		<description>[...] the comments to my previous article, &#8220;An alternative to requestAction&#8220;, it was mentioned that it is illogical to define helpers in the controller but to use them [...]</description>
		<content:encoded><![CDATA[<p>[...] the comments to my previous article, &#8220;An alternative to requestAction&#8220;, it was mentioned that it is illogical to define helpers in the controller but to use them [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rafaelbandeira3</title>
		<link>http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/comment-page-1/#comment-103918</link>
		<dc:creator>rafaelbandeira3</dc:creator>
		<pubDate>Thu, 21 Aug 2008 16:59:40 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=717#comment-103918</guid>
		<description>@cakebaker, Martin : didn&#039;t like Teknoid&#039;s approach. For sure it&#039;s creative and new, but it envolves many layers of the app, sounds too dirty and not very simple.

@cakebaker : but you noticed that I didn&#039;t like the approach of loading models in the view template? Controller has the beforeRender method, if you mind about logic, you could set your helpers there, after all, it&#039;s totally connected with the rendering process... seems more logical, no?</description>
		<content:encoded><![CDATA[<p>@cakebaker, Martin : didn&#8217;t like Teknoid&#8217;s approach. For sure it&#8217;s creative and new, but it envolves many layers of the app, sounds too dirty and not very simple.</p>
<p>@cakebaker : but you noticed that I didn&#8217;t like the approach of loading models in the view template? Controller has the beforeRender method, if you mind about logic, you could set your helpers there, after all, it&#8217;s totally connected with the rendering process&#8230; seems more logical, no?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/comment-page-1/#comment-103912</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 21 Aug 2008 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=717#comment-103912</guid>
		<description>@all: Thanks for your comments!

@Brendon: Hm, if you have to use model data in views rendered by the PagesController you should consider to use a separate controller and then push the data with the set method to the views. The PagesController is meant for rendering static pages.

@Kim: Wow, quite a performance difference! You should open an enhancement ticket ;-)

@Daniel: Yes, that&#039;s the approach I usually use when I need some data in all views. 

@Martin: Yes, teknoid&#039;s approach looks very interesting. 

@Rafael, Tarique: I agree with you that it is a bit illogical to define helpers in the controller but to use them in the views. At the moment I don&#039;t see a better solution than creating them in the view as shown by Rafael. But I have to think more about it ;-)</description>
		<content:encoded><![CDATA[<p>@all: Thanks for your comments!</p>
<p>@Brendon: Hm, if you have to use model data in views rendered by the PagesController you should consider to use a separate controller and then push the data with the set method to the views. The PagesController is meant for rendering static pages.</p>
<p>@Kim: Wow, quite a performance difference! You should open an enhancement ticket ;-)</p>
<p>@Daniel: Yes, that&#8217;s the approach I usually use when I need some data in all views. </p>
<p>@Martin: Yes, teknoid&#8217;s approach looks very interesting. </p>
<p>@Rafael, Tarique: I agree with you that it is a bit illogical to define helpers in the controller but to use them in the views. At the moment I don&#8217;t see a better solution than creating them in the view as shown by Rafael. But I have to think more about it ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rafaelbandeira3</title>
		<link>http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/comment-page-1/#comment-103893</link>
		<dc:creator>rafaelbandeira3</dc:creator>
		<pubDate>Thu, 21 Aug 2008 12:25:18 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=717#comment-103893</guid>
		<description>@Tarique Sani : your&#039;re right again. Now, not about being strictly logical them, but following K.I.S.S. ... isn&#039;t it nice to just have things being done on your view? like
MODEL - data /
CONTROLLER - setup /
VIEW - display /

I got your point, and it&#039;s really considerably interesting, I just don&#039;t think it&#039;s necessary/clean/simple... :)

I use TimeHelper outside views...</description>
		<content:encoded><![CDATA[<p>@Tarique Sani : your&#8217;re right again. Now, not about being strictly logical them, but following K.I.S.S. &#8230; isn&#8217;t it nice to just have things being done on your view? like<br />
MODEL &#8211; data /<br />
CONTROLLER &#8211; setup /<br />
VIEW &#8211; display /</p>
<p>I got your point, and it&#8217;s really considerably interesting, I just don&#8217;t think it&#8217;s necessary/clean/simple&#8230; :)</p>
<p>I use TimeHelper outside views&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tarique Sani</title>
		<link>http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/comment-page-1/#comment-103892</link>
		<dc:creator>Tarique Sani</dc:creator>
		<pubDate>Thu, 21 Aug 2008 12:16:54 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=717#comment-103892</guid>
		<description>@Rafael - I prefer my controller to be skinny, clean and easy to follow, the whole point of OOP is abstraction. 

Where do we define which Behaviours a model uses - in the model 
Where do we define which Components a controller uses - in the controller

Do controllers use helpers? No! Views use helpers! QED</description>
		<content:encoded><![CDATA[<p>@Rafael &#8211; I prefer my controller to be skinny, clean and easy to follow, the whole point of OOP is abstraction. </p>
<p>Where do we define which Behaviours a model uses &#8211; in the model<br />
Where do we define which Components a controller uses &#8211; in the controller</p>
<p>Do controllers use helpers? No! Views use helpers! QED</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rafaelbandeira3</title>
		<link>http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/comment-page-1/#comment-103891</link>
		<dc:creator>rafaelbandeira3</dc:creator>
		<pubDate>Thu, 21 Aug 2008 12:07:06 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=717#comment-103891</guid>
		<description>@Tarique Sani : me neither... i&#039;m worried about my clean views! :)

Ok, I think data controller&#039;s actions shouldn&#039;t behave different independently of the content type being requested as you said, but your idea seems just too abstract for me... I can&#039;t see a good reason for that... not even a logical reason, as I presented a logical reason for controllers do that...</description>
		<content:encoded><![CDATA[<p>@Tarique Sani : me neither&#8230; i&#8217;m worried about my clean views! :)</p>
<p>Ok, I think data controller&#8217;s actions shouldn&#8217;t behave different independently of the content type being requested as you said, but your idea seems just too abstract for me&#8230; I can&#8217;t see a good reason for that&#8230; not even a logical reason, as I presented a logical reason for controllers do that&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tarique Sani</title>
		<link>http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/comment-page-1/#comment-103890</link>
		<dc:creator>Tarique Sani</dc:creator>
		<pubDate>Thu, 21 Aug 2008 11:54:37 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=717#comment-103890</guid>
		<description>@Rafael - oh! at this stage I am not worried about the implementation, just that it would be a worthy idea to investigate. 

IMO actions per-se need not be aware of what *kind* of view (RSS, JSON, PDF) is being rendered hence they need not bother about which helpers to load.</description>
		<content:encoded><![CDATA[<p>@Rafael &#8211; oh! at this stage I am not worried about the implementation, just that it would be a worthy idea to investigate. </p>
<p>IMO actions per-se need not be aware of what *kind* of view (RSS, JSON, PDF) is being rendered hence they need not bother about which helpers to load.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rafaelbandeira3</title>
		<link>http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/comment-page-1/#comment-103888</link>
		<dc:creator>rafaelbandeira3</dc:creator>
		<pubDate>Thu, 21 Aug 2008 11:43:52 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=717#comment-103888</guid>
		<description>the code was cutted off ... :( 

&lt;code&gt;
//views/modules/posts/view.ctp
&lt;?php
$view = new ViewHelper(); // what about the inner Helpers?
$js = new JavascriptHelper();
$html = new HtmlHelper();
//or
$this-&gt;loadHelper(&#039;Rss&#039;, &#039;Html&#039;, &#039;Javascript&#039;); // how would the var be extracted?
// or
echo $this-&gt;Js-&gt;object($data); // too big...
?&gt;
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>the code was cutted off &#8230; :( </p>
<pre><code>//views/modules/posts/view.ctp
&lt;?php
$view = new ViewHelper(); // what about the inner Helpers?
$js = new JavascriptHelper();
$html = new HtmlHelper();
//or
$this-&gt;loadHelper('Rss', 'Html', 'Javascript'); // how would the var be extracted?
// or
echo $this-&gt;Js-&gt;object($data); // too big...
?&gt;</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: rafaelbandeira3</title>
		<link>http://cakebaker.42dh.com/2008/08/20/an-alternative-to-requestaction/comment-page-1/#comment-103887</link>
		<dc:creator>rafaelbandeira3</dc:creator>
		<pubDate>Thu, 21 Aug 2008 11:40:55 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=717#comment-103887</guid>
		<description>@Tarique Sani : ok, you have a point... but remember that all that is going to be used in the view - at least in the template - is in the knowing domain of your controller&#039;s action, so it&#039;s pretty logical to let it define wich helpers should be used or not. As in your view you will be inside of your controller&#039;s action domain, there&#039;s no reason to have a set of include like instantiations...
//views/modules/posts/view.ctp
loadHelper(&#039;Rss&#039;); // how would the var be extracted?
// or
echo $this-&gt;Js-&gt;object($data); // too big...
?&gt;

Is it worthy?</description>
		<content:encoded><![CDATA[<p>@Tarique Sani : ok, you have a point&#8230; but remember that all that is going to be used in the view &#8211; at least in the template &#8211; is in the knowing domain of your controller&#8217;s action, so it&#8217;s pretty logical to let it define wich helpers should be used or not. As in your view you will be inside of your controller&#8217;s action domain, there&#8217;s no reason to have a set of include like instantiations&#8230;<br />
//views/modules/posts/view.ctp<br />
loadHelper(&#8216;Rss&#8217;); // how would the var be extracted?<br />
// or<br />
echo $this-&gt;Js-&gt;object($data); // too big&#8230;<br />
?&gt;</p>
<p>Is it worthy?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
