Re: generatetreelist; similar function for retrieving depth
Yes, that would work too. Thanks :) (for some reason this message didn't get posted earlier) On 30 jul, 13:55, Jon Bennett wrote: > you could use getpath, eg: > > count($this->Model->getpath($id, array('id'))); > > hth > > Jon Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: generatetreelist; similar function for retrieving depth
Yes, that would work too. Thanks :) On 30 jul, 13:55, Jon Bennett wrote: > you could use getpath, eg: > > count($this->Model->getpath($id, array('id'))); > > hth > > Jon > > On 30 July 2010 12:45, Tomatosoup wrote: > > > > > > > Hello, > > > Does anybody know of a function likegeneratetreelistthat seperates > > the depth from the value. Instead of counting the spacer chars. > > > I saw an SQL query in the explanation page of MySQL. > > It's this > > page:http://dev.mysql.com/tech-resources/articles/hierarchical-data.html > > > This is the query: > > SELECT node.name, (COUNT(parent.name) - 1) AS depth > > FROM nested_category AS node, > > nested_category AS parent > > WHERE node.lft BETWEEN parent.lft AND parent.rgt > > GROUP BY node.name > > ORDER BY node.lft; > > > I don't know how I would use this query with find. > > Though I could use the custom-query-function. > > > The thing is; I would like to seperate depth and the value of my tree > > (categories). Then I can filter it withhtmlentities(the category > > names), without usinghtmlentitieson the spacer. > > > So if anybody can point me in the right direction I would be very > > pleased. > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > You received this message because you are subscribed to the Google Groups > > "CakePHP" group. > > To post to this group, send email to cake-php@googlegroups.com > > To unsubscribe from this group, send email to > > cake-php+unsubscr...@googlegroups.com For more options, visit this group > > athttp://groups.google.com/group/cake-php?hl=en > > -- > jon bennett -www.jben.net- blog.jben.net Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: generatetreelist; similar function for retrieving depth
Thanks :) I'll look into that. On 30 jul, 14:28, cricket wrote: > On Fri, Jul 30, 2010 at 7:45 AM, Tomatosoup > wrote: > > Hello, > > > Does anybody know of a function likegeneratetreelistthat seperates > > the depth from the value. Instead of counting the spacer chars. > > > I saw an SQL query in the explanation page of MySQL. > > It's this > > page:http://dev.mysql.com/tech-resources/articles/hierarchical-data.html > > > This is the query: > > SELECT node.name, (COUNT(parent.name) - 1) AS depth > > FROM nested_category AS node, > > nested_category AS parent > > WHERE node.lft BETWEEN parent.lft AND parent.rgt > > GROUP BY node.name > > ORDER BY node.lft; > > > I don't know how I would use this query with find. > > Though I could use the custom-query-function. > > > The thing is; I would like to seperate depth and the value of my tree > > (categories). Then I can filter it withhtmlentities(the category > > names), without usinghtmlentitieson the spacer. > > If what you want to do is to display the entries differently based on > their depth, you could do this with TreeHelper. > > http://bakery.cakephp.org/articles/view/tree-helper-1 > > Note the last part of the article, "Variables available in your > element". You use these like: > > if ($depth == 0) > { > $tree->addItemAttribute('class', 'Section'); > > } > > if ($hasChildren) > { > $tree->addItemAttribute('class', 'Parent'); > > } > > In this case, a node at top (depth == 0) gets a Section class. If it > has children, it also gets Parent class. This code is inside an > element named "nav_nodes". It's loaded from within another element > called "nav": > > echo $tree->generate( > $section_nodes, > array( > 'element' => 'sections/nav_node', > 'model' => 'Section' > ) > ); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: generatetreelist; similar function for retrieving depth
On Fri, Jul 30, 2010 at 7:45 AM, Tomatosoup wrote: > Hello, > > Does anybody know of a function like generatetreelist that seperates > the depth from the value. Instead of counting the spacer chars. > > I saw an SQL query in the explanation page of MySQL. > It's this page: > http://dev.mysql.com/tech-resources/articles/hierarchical-data.html > > This is the query: > SELECT node.name, (COUNT(parent.name) - 1) AS depth > FROM nested_category AS node, > nested_category AS parent > WHERE node.lft BETWEEN parent.lft AND parent.rgt > GROUP BY node.name > ORDER BY node.lft; > > > I don't know how I would use this query with find. > Though I could use the custom-query-function. > > The thing is; I would like to seperate depth and the value of my tree > (categories). Then I can filter it with htmlentities (the category > names), without using htmlentities on the spacer. If what you want to do is to display the entries differently based on their depth, you could do this with TreeHelper. http://bakery.cakephp.org/articles/view/tree-helper-1 Note the last part of the article, "Variables available in your element". You use these like: if ($depth == 0) { $tree->addItemAttribute('class', 'Section'); } if ($hasChildren) { $tree->addItemAttribute('class', 'Parent'); } In this case, a node at top (depth == 0) gets a Section class. If it has children, it also gets Parent class. This code is inside an element named "nav_nodes". It's loaded from within another element called "nav": echo $tree->generate( $section_nodes, array( 'element' => 'sections/nav_node', 'model' => 'Section' ) ); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: generatetreelist; similar function for retrieving depth
you could use getpath, eg: count($this->Model->getpath($id, array('id'))); hth Jon On 30 July 2010 12:45, Tomatosoup wrote: > Hello, > > Does anybody know of a function like generatetreelist that seperates > the depth from the value. Instead of counting the spacer chars. > > I saw an SQL query in the explanation page of MySQL. > It's this page: > http://dev.mysql.com/tech-resources/articles/hierarchical-data.html > > This is the query: > SELECT node.name, (COUNT(parent.name) - 1) AS depth > FROM nested_category AS node, > nested_category AS parent > WHERE node.lft BETWEEN parent.lft AND parent.rgt > GROUP BY node.name > ORDER BY node.lft; > > > I don't know how I would use this query with find. > Though I could use the custom-query-function. > > The thing is; I would like to seperate depth and the value of my tree > (categories). Then I can filter it with htmlentities (the category > names), without using htmlentities on the spacer. > > So if anybody can point me in the right direction I would be very > pleased. > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to cake-php@googlegroups.com > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > -- jon bennett - www.jben.net - blog.jben.net Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
generatetreelist; similar function for retrieving depth
Hello, Does anybody know of a function like generatetreelist that seperates the depth from the value. Instead of counting the spacer chars. I saw an SQL query in the explanation page of MySQL. It's this page: http://dev.mysql.com/tech-resources/articles/hierarchical-data.html This is the query: SELECT node.name, (COUNT(parent.name) - 1) AS depth FROM nested_category AS node, nested_category AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt GROUP BY node.name ORDER BY node.lft; I don't know how I would use this query with find. Though I could use the custom-query-function. The thing is; I would like to seperate depth and the value of my tree (categories). Then I can filter it with htmlentities (the category names), without using htmlentities on the spacer. So if anybody can point me in the right direction I would be very pleased. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en