<?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: Adding Better Scope Limiting to CakePHP 1.2&#8242;s Tree Behavior</title>
	<atom:link href="http://jamienay.com/2010/01/adding-better-scope-limiting-to-cakephp-1-2s-tree-behavior/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamienay.com/2010/01/adding-better-scope-limiting-to-cakephp-1-2s-tree-behavior/</link>
	<description>A PHP web developer writing about the web.</description>
	<lastBuildDate>Mon, 26 Jul 2010 20:07:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Abba Bryant</title>
		<link>http://jamienay.com/2010/01/adding-better-scope-limiting-to-cakephp-1-2s-tree-behavior/comment-page-1/#comment-4557</link>
		<dc:creator>Abba Bryant</dc:creator>
		<pubDate>Wed, 20 Jan 2010 01:17:34 +0000</pubDate>
		<guid isPermaLink="false">http://jamienay.com/?p=505#comment-4557</guid>
		<description>I knew I had seen something that addressed this issue in the past, without resorting to rewriting parts of the behavior - not that I am against that if it is needed.

Basically, the scope adds a condition to the queries, but since you don&#039;t know the foreign_key id ahead of time for the related Model&#039;s record you are limited when using $actsAs to setting either a static value..

i.e. &#039;scope&#039; =&gt; array( &#039;RelatedModel.field&#039; =&gt; 23 )

*OR* you can attach and detach on the fly ala
http://www.mcfarren.org/CodeCakePHPStoringMultipleTreesWithTreeBehavior</description>
		<content:encoded><![CDATA[<p>I knew I had seen something that addressed this issue in the past, without resorting to rewriting parts of the behavior &#8211; not that I am against that if it is needed.</p>
<p>Basically, the scope adds a condition to the queries, but since you don&#8217;t know the foreign_key id ahead of time for the related Model&#8217;s record you are limited when using $actsAs to setting either a static value..</p>
<p>i.e. &#8216;scope&#8217; =&gt; array( &#8216;RelatedModel.field&#8217; =&gt; 23 )</p>
<p>*OR* you can attach and detach on the fly ala<br />
<a href="http://www.mcfarren.org/CodeCakePHPStoringMultipleTreesWithTreeBehavior" rel="nofollow">http://www.mcfarren.org/CodeCakePHPStoringMultipleTreesWithTreeBehavior</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://jamienay.com/2010/01/adding-better-scope-limiting-to-cakephp-1-2s-tree-behavior/comment-page-1/#comment-4397</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Sun, 10 Jan 2010 17:14:23 +0000</pubDate>
		<guid isPermaLink="false">http://jamienay.com/?p=505#comment-4397</guid>
		<description>This is exactly what I needed!

I found another behavior for this on the Bakery but decided to use yours because it seems to deviate less from the core.

(other behavior:
http://bakery.cakephp.org/articles/view/scopedtreebehavior
)</description>
		<content:encoded><![CDATA[<p>This is exactly what I needed!</p>
<p>I found another behavior for this on the Bakery but decided to use yours because it seems to deviate less from the core.</p>
<p>(other behavior:<br />
<a href="http://bakery.cakephp.org/articles/view/scopedtreebehavior" rel="nofollow">http://bakery.cakephp.org/articles/view/scopedtreebehavior</a><br />
)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie</title>
		<link>http://jamienay.com/2010/01/adding-better-scope-limiting-to-cakephp-1-2s-tree-behavior/comment-page-1/#comment-4338</link>
		<dc:creator>Jamie</dc:creator>
		<pubDate>Fri, 08 Jan 2010 07:05:04 +0000</pubDate>
		<guid isPermaLink="false">http://jamienay.com/?p=505#comment-4338</guid>
		<description>Oops, looks like my bakery article (which I wrote months ago and don&#039;t even like anymore!) finally got posted a couple of days ago. I take back my bitterness. ;)</description>
		<content:encoded><![CDATA[<p>Oops, looks like my bakery article (which I wrote months ago and don&#8217;t even like anymore!) finally got posted a couple of days ago. I take back my bitterness. <img src='http://jamienay.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie</title>
		<link>http://jamienay.com/2010/01/adding-better-scope-limiting-to-cakephp-1-2s-tree-behavior/comment-page-1/#comment-4336</link>
		<dc:creator>Jamie</dc:creator>
		<pubDate>Fri, 08 Jan 2010 05:35:20 +0000</pubDate>
		<guid isPermaLink="false">http://jamienay.com/?p=505#comment-4336</guid>
		<description>Neil: Interesting code on the bakery - I hadn&#039;t seen it. I don&#039;t check the bakery all too often these days since I&#039;m still waiting for one that I posted months ago to be approved. Yes, I&#039;m bitter. :)

As for the scope option - yes and no. Scope for TreeBehavior can be used to add simple find conditions, just like counterScope for counterCache. But you can also pass the name of an associated belongsTo model, as TreeBehavior::setup() shows. Since this feature is undocumented, I had thought (naively perhaps) that it would add a find condition to reordering operations so that only other records in the table with the same belongsTo foreign model would be affected.

So, you pass a &quot;NavList&quot; as the scope and TreeBehavior ensures that only NavItems with the same nav_list_id as the record you&#039;re manipulating get included in tree-restructuring. But obviously that didn&#039;t turn out to be the case. Instead placing a condition like this on reordering operations:

NavItem.nav_list_id = 7 // assuming &quot;7&quot; is the nav_list_id for the current record

The stock TreeBehavior just inserts this:

NavItem.nav_list_id = NavList.id

which is useful in some cases but not when you want to maintain separate trees within the same table.</description>
		<content:encoded><![CDATA[<p>Neil: Interesting code on the bakery &#8211; I hadn&#8217;t seen it. I don&#8217;t check the bakery all too often these days since I&#8217;m still waiting for one that I posted months ago to be approved. Yes, I&#8217;m bitter. <img src='http://jamienay.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>As for the scope option &#8211; yes and no. Scope for TreeBehavior can be used to add simple find conditions, just like counterScope for counterCache. But you can also pass the name of an associated belongsTo model, as TreeBehavior::setup() shows. Since this feature is undocumented, I had thought (naively perhaps) that it would add a find condition to reordering operations so that only other records in the table with the same belongsTo foreign model would be affected.</p>
<p>So, you pass a &#8220;NavList&#8221; as the scope and TreeBehavior ensures that only NavItems with the same nav_list_id as the record you&#8217;re manipulating get included in tree-restructuring. But obviously that didn&#8217;t turn out to be the case. Instead placing a condition like this on reordering operations:</p>
<p>NavItem.nav_list_id = 7 // assuming &#8220;7&#8243; is the nav_list_id for the current record</p>
<p>The stock TreeBehavior just inserts this:</p>
<p>NavItem.nav_list_id = NavList.id</p>
<p>which is useful in some cases but not when you want to maintain separate trees within the same table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Connolly</title>
		<link>http://jamienay.com/2010/01/adding-better-scope-limiting-to-cakephp-1-2s-tree-behavior/comment-page-1/#comment-4335</link>
		<dc:creator>Daniel Connolly</dc:creator>
		<pubDate>Fri, 08 Jan 2010 05:31:57 +0000</pubDate>
		<guid isPermaLink="false">http://jamienay.com/?p=505#comment-4335</guid>
		<description>Thanks for posting this.  Seems to work great for me.</description>
		<content:encoded><![CDATA[<p>Thanks for posting this.  Seems to work great for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil Crookes</title>
		<link>http://jamienay.com/2010/01/adding-better-scope-limiting-to-cakephp-1-2s-tree-behavior/comment-page-1/#comment-4319</link>
		<dc:creator>Neil Crookes</dc:creator>
		<pubDate>Thu, 07 Jan 2010 09:13:55 +0000</pubDate>
		<guid isPermaLink="false">http://jamienay.com/?p=505#comment-4319</guid>
		<description>Does the scope option not work like counterScope for counterCache? I.e. an array like you&#039;d pass to find conditions?

Also, this just got posted on the Bakery : http://bakery.cakephp.org/articles/view/btree-behavior ?</description>
		<content:encoded><![CDATA[<p>Does the scope option not work like counterScope for counterCache? I.e. an array like you&#8217;d pass to find conditions?</p>
<p>Also, this just got posted on the Bakery : <a href="http://bakery.cakephp.org/articles/view/btree-behavior" rel="nofollow">http://bakery.cakephp.org/articles/view/btree-behavior</a> ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
