Re: generateTreeList starting from an id

2015-11-24 Thread Lê Minh Thành
work for me


Vào 20:45:23 UTC+7 Thứ Sáu, ngày 16 tháng 3 năm 2012, gimmebucks đã viết:
>
> What i always do is get the node lft and rght value. 
> then set conditions array('Model.lft >' => $node['lft'],'Model.rght <' 
> => $node['rght']) 
> to include the node, substitute > with >= and < with <= 
>
> On Mar 16, 12:06 am, Ernesto <e.fanz...@gmail.com> wrote: 
> > i forgot to say i've already tried the "conditions" argument but the 
> > function will return just the first layer of results 
> > 
> > Il giorno giovedì 15 marzo 2012 16:49:30 UTC+1, Ernesto ha scritto: 
> > 
> > 
> > 
> > > Hi all. 
> > 
> > > i'm using TreeBehavior in one of my Models and everything is working 
> ok. 
> > 
> > > just one question: 
> > > generateTreeList returns a list containing ALL the entries in the 
> table. 
> > 
> > > i want the treeList just for the category with id = 20 and his 
> childrens 
> > 
> > > how can i do? 
> > 
> > Il giorno giovedì 15 marzo 2012 16:49:30 UTC+1, Ernesto ha scritto: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > Hi all. 
> > 
> > > i'm using TreeBehavior in one of my Models and everything is working 
> ok. 
> > 
> > > just one question: 
> > > generateTreeList returns a list containing ALL the entries in the 
> table. 
> > 
> > > i want the treeList just for the category with id = 20 and his 
> childrens 
> > 
> > > how can i do?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: actAs Tree : generatetreelist error

2012-07-03 Thread Davor Ilic
goog to know thank you

2012/6/18 Ish ish1...@gmail.com

 Had the same problem in cakephp 2.0

 Later realized *generatetreelist* function got renamed to *
 generateTreeList*

 On Thursday, January 27, 2011 9:44:58 PM UTC-5, raymond wrote:

 Hi.
 I have tried Tree behavior just according to manual, but it reports
 error following:

 Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
 check the manual that corresponds to your MySQL server version for the
 right syntax to use near 'generatetreelist' at line 1
 Query: generatetreelist

 I debugged and found that cakePHP does not understand the method
 generatetreelist()

 I have created table 'lkp_itemcate' with following columns:
 id, parent_id, lft, rght, name, img_url, level, created, modified.

 And then created model file:

 class Itemcate extends AppModel {
 var $name = 'Itemcate';
 var $tablePrefix = 'lkp_';
 var $useTable = 'itemcate';

 var $actAs = array('Tree');
 }

 and inserted following code to controller action:

 $list = $this-Itemcate-**generatetreelist(null, null, null,
 'nbsp;nbsp;nbsp;');

 Any advice?
 Thanks.

  --
 Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
 Check out the new CakePHP Questions site http://ask.cakephp.org and help
 others with their CakePHP related questions.


 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


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: actAs Tree : generatetreelist error

2012-06-18 Thread Ish
Had the same problem in cakephp 2.0

Later realized *generatetreelist* function got renamed to *generateTreeList*

On Thursday, January 27, 2011 9:44:58 PM UTC-5, raymond wrote:

 Hi. 
 I have tried Tree behavior just according to manual, but it reports 
 error following: 

 Warning (512): SQL Error: 1064: You have an error in your SQL syntax; 
 check the manual that corresponds to your MySQL server version for the 
 right syntax to use near 'generatetreelist' at line 1 
 Query: generatetreelist 

 I debugged and found that cakePHP does not understand the method 
 generatetreelist() 

 I have created table 'lkp_itemcate' with following columns: 
 id, parent_id, lft, rght, name, img_url, level, created, modified. 

 And then created model file: 

 class Itemcate extends AppModel { 
 var $name = 'Itemcate'; 
 var $tablePrefix = 'lkp_'; 
 var $useTable = 'itemcate'; 

 var $actAs = array('Tree'); 
 } 

 and inserted following code to controller action: 

 $list = $this-Itemcate-generatetreelist(null, null, null, 
 'nbsp;nbsp;nbsp;'); 

 Any advice? 
 Thanks. 



-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: generateTreeList starting from an id

2012-03-16 Thread gimmebucks
What i always do is get the node lft and rght value.
then set conditions array('Model.lft ' = $node['lft'],'Model.rght '
= $node['rght'])
to include the node, substitute  with = and  with =

On Mar 16, 12:06 am, Ernesto e.fanz...@gmail.com wrote:
 i forgot to say i've already tried the conditions argument but the
 function will return just the first layer of results

 Il giorno giovedì 15 marzo 2012 16:49:30 UTC+1, Ernesto ha scritto:



  Hi all.

  i'm using TreeBehavior in one of my Models and everything is working ok.

  just one question:
  generateTreeList returns a list containing ALL the entries in the table.

  i want the treeList just for the category with id = 20 and his childrens

  how can i do?

 Il giorno giovedì 15 marzo 2012 16:49:30 UTC+1, Ernesto ha scritto:









  Hi all.

  i'm using TreeBehavior in one of my Models and everything is working ok.

  just one question:
  generateTreeList returns a list containing ALL the entries in the table.

  i want the treeList just for the category with id = 20 and his childrens

  how can i do?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


generateTreeList starting from an id

2012-03-15 Thread Ernesto
Hi all.

i'm using TreeBehavior in one of my Models and everything is working ok.

just one question:
generateTreeList returns a list containing ALL the entries in the table.

i want the treeList just for the category with id = 20 and his childrens

how can i do?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: generateTreeList starting from an id

2012-03-15 Thread Ernesto
i forgot to say i've already tried the conditions argument but the 
function will return just the first layer of results

Il giorno giovedì 15 marzo 2012 16:49:30 UTC+1, Ernesto ha scritto:

 Hi all.

 i'm using TreeBehavior in one of my Models and everything is working ok.

 just one question:
 generateTreeList returns a list containing ALL the entries in the table.

 i want the treeList just for the category with id = 20 and his childrens

 how can i do?


Il giorno giovedì 15 marzo 2012 16:49:30 UTC+1, Ernesto ha scritto:

 Hi all.

 i'm using TreeBehavior in one of my Models and everything is working ok.

 just one question:
 generateTreeList returns a list containing ALL the entries in the table.

 i want the treeList just for the category with id = 20 and his childrens

 how can i do?


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Retrieve extra field with generatetreelist

2011-10-23 Thread MetZ
Hi...

Sooo.. no suggestions?

$categories = $this-Category-generatetreelist(null, null, null, '|--
', $recursive = -1 );

Looking to retrieve the extra field Category.published and display
it in my html table.

Should I use another find and merge them or something?

Using this in view:
table class=data display
thead
tr
th 
style=text-align:center;?php __('Id');?/th
th?php 
__('Name');?/th
th style=text-align:center;?php
__('Status');?/th
th 
style=text-align:center;?php __('Actions');?/th
/tr
/thead
tbody
?php   $i = 0;
foreach ($categories as $key=$value):
$class = null;
if ($i++ % 2 == 0) {
$class = 'odd';
}
$edit = $html-link($html-image(icons/16_icon_edit.png),
array('action' = 'edit', $key), array('title'='Endre','escape' =
false));
$delete = $html-link($html-image(icons/
16_icon_delete.png), array('action' = 'delete', $key),
array('valign'='center','class'='delete_trigger','rel'='#error','title'='Slett','escape'
= false));
?

tr class=?php echo $class;? gradeA
td class=center?php echo $key; ?/td
td?php echo $value; ?/td
td class=centerN/A/td
td class=center?php echo $edit; ? nbsp;?php echo $delete; ?
/td
   /tr
?php endforeach; ?
/tbody
/table


On 19 Okt, 18:48, MetZ met...@gmail.com wrote:
 Hi all.
 I am wondering how I can retrieve an extra field from my rows using
 generatetreelist?
 $this-data = $this-Category-generatetreelist(null, null, null,
 'nbsp;nbsp;nbsp;');

 The field I am looking for is status, to display if the category is
 active or not.

 And,, btw.. I am using generatetreelist to list all nested categories
 in a html table with children.
 If u know of a better way to get all categories, and to put everything
 in an array to output in a html table, please let me know ;)

 Thanks for all and any help!
 Regards!
 -Tom

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Retrieve extra field with generatetreelist

2011-10-23 Thread #2Will
You can speficy the field to use as the value, but i think only one
field havn't tried though...

$tasks = $this-Category-generateTreeList(null, null,
'{n}.Category.status', -);

you could make a combinded field in the model.

What i have done in the past is order by lft to get the records in
order but with the whole row available.

$categories = $this-Category-find('all',
array('order'=array('Category.lft asc')))  ;


hth

On Oct 24, 5:32 am, MetZ met...@gmail.com wrote:
 Hi...

 Sooo.. no suggestions?

 $categories = $this-Category-generatetreelist(null, null, null, '|--
 ', $recursive = -1 );

 Looking to retrieve the extra field Category.published and display
 it in my html table.

 Should I use another find and merge them or something?

 Using this in view:
 table class=data display
                                         thead
                                                 tr
                                                         th 
 style=text-align:center;?php __('Id');?/th
                                                         th?php 
 __('Name');?/th
                             th style=text-align:center;?php
 __('Status');?/th
                                                         th 
 style=text-align:center;?php __('Actions');?/th
                                                 /tr
                                         /thead
                                         tbody
 ?php        $i = 0;
                 foreach ($categories as $key=$value):
                 $class = null;
                 if ($i++ % 2 == 0) {
                 $class = 'odd';
                 }
                 $edit = $html-link($html-image(icons/16_icon_edit.png),
 array('action' = 'edit', $key), array('title'='Endre','escape' =
 false));
         $delete = $html-link($html-image(icons/
 16_icon_delete.png), array('action' = 'delete', $key),
 array('valign'='center','class'='delete_trigger','rel'='#error','title'= 
 'Slett','escape'
 = false));
         ?

     tr class=?php echo $class;? gradeA
     td class=center?php echo $key; ?/td
     td?php echo $value; ?/td
     td class=centerN/A/td
     td class=center?php echo $edit; ? nbsp;?php echo $delete; ?/td

    /tr
 ?php endforeach; ?
 /tbody
 /table

 On 19 Okt, 18:48, MetZ met...@gmail.com wrote:







  Hi all.
  I am wondering how I can retrieve an extra field from my rows using
  generatetreelist?
  $this-data = $this-Category-generatetreelist(null, null, null,
  'nbsp;nbsp;nbsp;');

  The field I am looking for is status, to display if the category is
  active or not.

  And,, btw.. I am using generatetreelist to list all nested categories
  in a html table with children.
  If u know of a better way to get all categories, and to put everything
  in an array to output in a html table, please let me know ;)

  Thanks for all and any help!
  Regards!
  -Tom

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Pagination generatetreelist results

2011-10-19 Thread Constantin.FF
I need to paginate the results of generatetreelist together with the
Posts results.
Already I have
 $this-paginate('Post' );
but also I need the treelist of the posts. I can do this by if check
before the display of posts in the view or merging the arrays in the
controller but is there more simple and faster way for limiting the
results?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Retrieve extra field with generatetreelist

2011-10-19 Thread MetZ
Hi all.
I am wondering how I can retrieve an extra field from my rows using
generatetreelist?
$this-data = $this-Category-generatetreelist(null, null, null,
'nbsp;nbsp;nbsp;');

The field I am looking for is status, to display if the category is
active or not.

And,, btw.. I am using generatetreelist to list all nested categories
in a html table with children.
If u know of a better way to get all categories, and to put everything
in an array to output in a html table, please let me know ;)


Thanks for all and any help!
Regards!
-Tom

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Retrieve extra field with generatetreelist

2011-10-19 Thread Dee Johnson
http://book.cakephp.org/view/1348/generatetreelist

I have not used generaltreelist personally but based on the docs above it 
seems that it works just like 'find' and if you have your relationships set 
up correctly and you set the recursive attribute to bring back the 
appropriate data you should get that

if that is not the issue then please chime back in and one of the other guys 
more familiar with it will assist im sure.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Pagination generatetreelist results

2011-10-19 Thread Constantin.FF
the issue became a bit more complicated. Here is what I need as a
result.
I have the Post Model which behave as a Tree, and also every post has
a parent or for the first level the parent is 0. Also every post has a
sort number which helps for them to be sorted.
I wold like to display paginated results but the order to be as
follows:
First to be the post with lower sort number followed by it's children
(again sorted by their sort number), next grandchildren again sorted
and so on...
Next to be the second post with its children and so on 

I'm looking for the most appropriate way to do this. If I get the
generatetreelist the results are not ordered the way I need but just
ordered by ID and also not paginated. And if I try to display the
posts results , I can sort them only by one criteria and I need them
sorted by parent_id and sort number while keeping them groped by
parent_id.

Please if someone can give an idea how to solve this. Thanks

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Any Solution to Order a generatetreelist output

2011-04-16 Thread Mr.Jayesh
Hi Mates,

First off all, I would like to thank this group for being of great
support.
Guys, as in my project I was trying to display category list inside
select box. I am using Tree List, so what I have in my table is:
|  id  |  category  |  parent_id  |
Currently I am using generatetreelist() that generates a good
hierarchy of categories, but these are not in proper order.

I mean, I wanted to order it according to category field. I tried many
ways but didn't got the result, even later got confused while
searching for a solution.

May anyone please advice me a simple solution in this regards, would
be thankful.

Regards,
Jayesh

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Any Solution to Order a generatetreelist output

2011-04-16 Thread Tilen Majerle
if you are using Tree Behaviour the you need to use lft and rght field
and it will create an array based on this values...:)
--
Lep pozdrav, Tilen Majerle
http://majerle.eu



2011/4/16 Mr.Jayesh jayeshach...@gmail.com

 Hi Mates,

 First off all, I would like to thank this group for being of great
 support.
 Guys, as in my project I was trying to display category list inside
 select box. I am using Tree List, so what I have in my table is:
 |  id  |  category  |  parent_id  |
 Currently I am using generatetreelist() that generates a good
 hierarchy of categories, but these are not in proper order.

 I mean, I wanted to order it according to category field. I tried many
 ways but didn't got the result, even later got confused while
 searching for a solution.

 May anyone please advice me a simple solution in this regards, would
 be thankful.

 Regards,
 Jayesh

 --
 Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
 Check out the new CakePHP Questions site http://ask.cakephp.org and help
 others with their CakePHP related questions.


 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


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Any Solution to Order a generatetreelist output

2011-04-16 Thread Yuka Poppe
Hi Jayesh,

In the case of a Tree behaviour, the algorithm used to generate the
tree is based on ordering, its not very trivial to use ordering on the
regular sense on the tree, and maintain its structure at the same
time.

CakePHP's specific implemtation of this algorithm aside, one would
implement this feature by factoring this in at record creation time,
e.g. the complete tree's ordering is re-calculated whenever a new item
is added, and at this time one could calculate the lft and rght value
based on a tertiery factor, the category you mentioned.

I'm not sure if such a feature is built into the CakePHP
implementation of the MPTT algorithm. Its a pain to build it yourself.
Google MPTT (Modified Pre-ordered Tree Traversal) in order for some
more understanding of how the TreeBehavour and its ordering actually
works.

In short; Either you display the list as a tree, or you can display it
ordered by another column and its tree structure will be lost.

Regards, Yuka

On Sat, Apr 16, 2011 at 11:08 PM, Tilen Majerle tilen.maje...@gmail.com wrote:
 if you are using Tree Behaviour the you need to use lft and rght field
 and it will create an array based on this values...:)
 --
 Lep pozdrav, Tilen Majerle
 http://majerle.eu


 2011/4/16 Mr.Jayesh jayeshach...@gmail.com

 Hi Mates,

 First off all, I would like to thank this group for being of great
 support.
 Guys, as in my project I was trying to display category list inside
 select box. I am using Tree List, so what I have in my table is:
 |  id  |  category  |  parent_id  |
 Currently I am using generatetreelist() that generates a good
 hierarchy of categories, but these are not in proper order.

 I mean, I wanted to order it according to category field. I tried many
 ways but didn't got the result, even later got confused while
 searching for a solution.

 May anyone please advice me a simple solution in this regards, would
 be thankful.

 Regards,
 Jayesh

 --
 Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
 Check out the new CakePHP Questions site http://ask.cakephp.org and help
 others with their CakePHP related questions.


 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

 --
 Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
 Check out the new CakePHP Questions site http://ask.cakephp.org and help
 others with their CakePHP related questions.


 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


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Any Solution to Order a generatetreelist output

2011-04-16 Thread Nic
like stated above, you need 'lft' and 'rght' fields in your table.
check out this:  http://en.wikipedia.org/wiki/Nested_set_model nested set
model: wikipedia 
and you can figure out what to populate your fields with to start off.

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/Any-Solution-to-Order-a-generatetreelist-output-tp4308116p4308453.html
Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


actAs Tree : generatetreelist error

2011-01-29 Thread raymond
Hi.
I have tried Tree behavior just according to manual, but it reports
error following:

Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near 'generatetreelist' at line 1
Query: generatetreelist

I debugged and found that cakePHP does not understand the method
generatetreelist()

I have created table 'lkp_itemcate' with following columns:
id, parent_id, lft, rght, name, img_url, level, created, modified.

And then created model file:

class Itemcate extends AppModel {
var $name = 'Itemcate';
var $tablePrefix = 'lkp_';
var $useTable = 'itemcate';

var $actAs = array('Tree');
}

and inserted following code to controller action:

$list = $this-Itemcate-generatetreelist(null, null, null,
'nbsp;nbsp;nbsp;');

Any advice?
Thanks.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: actAs Tree : generatetreelist error

2011-01-29 Thread Tilen Majerle
it's $actsAs = array('Tree'); //you forgot s
--
Lep pozdrav, Tilen Majerle
http://majerle.eu



2011/1/28 raymond raymond...@gmail.com

 Hi.
 I have tried Tree behavior just according to manual, but it reports
 error following:

 Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
 check the manual that corresponds to your MySQL server version for the
 right syntax to use near 'generatetreelist' at line 1
 Query: generatetreelist

 I debugged and found that cakePHP does not understand the method
 generatetreelist()

 I have created table 'lkp_itemcate' with following columns:
 id, parent_id, lft, rght, name, img_url, level, created, modified.

 And then created model file:

 class Itemcate extends AppModel {
var $name = 'Itemcate';
var $tablePrefix = 'lkp_';
var $useTable = 'itemcate';

var $actAs = array('Tree');
 }

 and inserted following code to controller action:

 $list = $this-Itemcate-generatetreelist(null, null, null,
 'nbsp;nbsp;nbsp;');

 Any advice?
 Thanks.

 --
 Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
 Check out the new CakePHP Questions site http://ask.cakephp.org and help
 others with their CakePHP related questions.


 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: actAs Tree : generatetreelist error

2011-01-29 Thread Jeremy Burns | Class Outfit
It's $actsAs, not $actAs.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 28 Jan 2011, at 02:44, raymond wrote:

 Hi.
 I have tried Tree behavior just according to manual, but it reports
 error following:
 
 Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
 check the manual that corresponds to your MySQL server version for the
 right syntax to use near 'generatetreelist' at line 1
 Query: generatetreelist
 
 I debugged and found that cakePHP does not understand the method
 generatetreelist()
 
 I have created table 'lkp_itemcate' with following columns:
 id, parent_id, lft, rght, name, img_url, level, created, modified.
 
 And then created model file:
 
 class Itemcate extends AppModel {
   var $name = 'Itemcate';
   var $tablePrefix = 'lkp_';
   var $useTable = 'itemcate';
 
   var $actAs = array('Tree');
 }
 
 and inserted following code to controller action:
 
 $list = $this-Itemcate-generatetreelist(null, null, null,
 'nbsp;nbsp;nbsp;');
 
 Any advice?
 Thanks.
 
 -- 
 Our newest site for the community: CakePHP Video Tutorials 
 http://tv.cakephp.org 
 Check out the new CakePHP Questions site http://ask.cakephp.org and help 
 others with their CakePHP related questions.
 
 
 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

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Want generatetreelist() results in alphabetical order

2010-11-26 Thread Johnny Cupcake
On Nov 22, 1:09 am, AD7six andydawso...@gmail.com wrote:


 I'd recommend looking at the reorder method, which'll do what you want
 to the data itself, unless you're wanting to sort by a different
 field.

 http://api.cakephp.org/view_source/tree-behavior/#l-628

Thanks, reorder() was in fact the first thing I tried.  It did not
reorder all the nodes as I desired, and as my solution in this thread
does.  Can't remember why.

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: Want generatetreelist() results in alphabetical order

2010-11-22 Thread AD7six


On Nov 22, 3:55 am, Johnny Cupcake sparklew...@hotmail.com wrote:
 OK, I decided to bake up a solution myself.  I don't contend that it
 is the fastest or the best, but it is simple and it seems to work.

Since MPTT doesn't care about sibling order, getting the wrong
result from generatetreelist just means your data is in the wrong
order in the db.

I'd recommend looking at the reorder method, which'll do what you want
to the data itself, unless you're wanting to sort by a different
field.

http://api.cakephp.org/view_source/tree-behavior/#l-628

AD

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


Want generatetreelist() results in alphabetical order

2010-11-21 Thread Johnny Cupcake
http://book.cakephp.org/view/1348/generatetreelist
generatetreelist() returns a pseudo-tree in a relative order, with
children under parents.  I would like results wherein the peers are
also ordered, alphabetically by label.  Here is a quick example if
this isn't clear:

array(
[1] =  My Categories,
[2] =  _Fun,
[3] =  __Sport,
[4] =  ___Surfing,
[16] = ___Skating,
)

This array is not fully ordered (to my liking anyway).  Surfing is
above Skating, when it should be below.  When an array contains dozens
of elements like this, it is difficult to find what you are looking
for (without alphabetical ordering).

The only past online discussions I can find on this issue, end with
If you want this solved, then write the function yourself.  So my
question is... has anyone wrote the solution yet?

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: Want generatetreelist() results in alphabetical order

2010-11-21 Thread Johnny Cupcake
OK, I decided to bake up a solution myself.  I don't contend that it
is the fastest or the best, but it is simple and it seems to work.
Drop these two functions into your model and call the first.

//
// Convert the results of a $this-find('threaded') call into a list,
wherein all items
// are ordered as a tree.  Unlike generatetreelist() (as of Cake
1.3), peers in this
// list are also ordered (however they were by the preceding
find() ).
// This is meant to be used in models with Tree behavior.
//
// Inputs:
//   $find_results - output from $this-find('threaded')
//   $table - the name of the model containing keys and values
//   $key - the name of the value in the model to become the key in
the output array (e.g. 'id')
//   $value - the name of value in the model to become the value in
the output array (e.g. 'name')
//
// Output: a flat, one-dimensional array similar to that from
generatetreelist()
//
function _threadedFindToTreeList($find_results, $table, $key, $value,
$spacer = '--')
{
$our_results = array();

$this-_threadedFindToTreeListR($find_results, $table, $key, 
$value,
$spacer, 0, $our_results);

return $our_results;
}

//
//
function _threadedFindToTreeListR($find_results, $table, $key,
$value, $spacer, $recursion_lvl, $our_results)
{
foreach($find_results as $item)
{
if ( isset($item[$table]) )
{
// Add one entry to the bottom of our 
accumulated results.
$spaced_val = '';
for ($i = 0; $i  $recursion_lvl; $i++)
$spaced_val .= $spacer;

$spaced_val .= $item[$table][$value];
$our_results[ $item[$table][$key] ] = 
$spaced_val;

if ( isset($item['children']) )

$this-_threadedFindToTreeListR($item['children'], $table, $key,
$value, $spacer, $recursion_lvl+1, $our_results);
}
}
}




On Nov 21, 6:12 pm, Johnny Cupcake sparklew...@hotmail.com wrote:
 http://book.cakephp.org/view/1348/generatetreelist
 generatetreelist() returns a pseudo-tree in a relative order, with
 children under parents.  I would like results wherein the peers are
 also ordered, alphabetically by label.  Here is a quick example if
 this isn't clear:

 array(
         [1] =  My Categories,
         [2] =  _Fun,
         [3] =  __Sport,
         [4] =  ___Surfing,
         [16] = ___Skating,
 )

 This array is not fully ordered (to my liking anyway).  Surfing is
 above Skating, when it should be below.  When an array contains dozens
 of elements like this, it is difficult to find what you are looking
 for (without alphabetical ordering).

 The only past online discussions I can find on this issue, end with
 If you want this solved, then write the function yourself.  So my
 question is... has anyone wrote the solution yet?

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

2010-07-30 Thread Tomatosoup
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


Re: generatetreelist; similar function for retrieving depth

2010-07-30 Thread Jon Bennett
you could use getpath, eg:

count($this-Model-getpath($id, array('id')));

hth

Jon

On 30 July 2010 12:45, Tomatosoup wiegersteenhui...@gmail.com 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


Re: generatetreelist; similar function for retrieving depth

2010-07-30 Thread cricket
On Fri, Jul 30, 2010 at 7:45 AM, Tomatosoup wiegersteenhui...@gmail.com 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

2010-07-30 Thread Tomatosoup
Thanks :)

I'll look into that.

On 30 jul, 14:28, cricket zijn.digi...@gmail.com wrote:
 On Fri, Jul 30, 2010 at 7:45 AM, Tomatosoup wiegersteenhui...@gmail.com 
 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

2010-07-30 Thread Tomatosoup
Yes, that would work too.
Thanks :)

On 30 jul, 13:55, Jon Bennett jmbenn...@gmail.com wrote:
 you could use getpath, eg:

 count($this-Model-getpath($id, array('id')));

 hth

 Jon

 On 30 July 2010 12:45, Tomatosoup wiegersteenhui...@gmail.com 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

2010-07-30 Thread Tomatosoup
Yes, that would work too.
Thanks :)

(for some reason this message didn't get posted earlier)

On 30 jul, 13:55, Jon Bennett jmbenn...@gmail.com 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, keypath, valuepath

2010-04-12 Thread dreamingmind
What I've seen is altering the final line of the generatetreelist()
method from:

 return Set::combine($results, $keyPath, $valuePath);

to

 return Set::combine($results);

allows the string path parameters to work. ?? What's up here?

Don

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

To unsubscribe, reply using remove me as the subject.


Re: generatetreelist, keypath, valuepath

2010-04-12 Thread dreamingmind
All right friends and neighbors. One last update I guess. I messed
around some more and found the 'recursive' parameter has to be set for
the string paths to operate if they point to any linked table. I'm
assuming, if you don't set a recursive level for the find, the value
is defaulting to suppress the retrieval of any but the first level
data. So, you could use keypath and value path to change what fields
you return from that first level table, but nothing else will be
available till you open up the find for deeper levels.

Don

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

To unsubscribe, reply using remove me as the subject.


generatetreelist, keypath, valuepath

2010-04-11 Thread dreamingmind
Am I missing something simple here regarding specifying string paths?

I've got two models, Navigator and Navline. Navigator has one Navline.
Navigator actsAs Tree.
Navigator-find('all') gets me this:
Array
(
[0] = Array
(
[Navigator] = Array
(
[id] = 37
[parent_id] = 36
[lft] = 2
[rght] = 3
[navline_id] = 1
)
[Navline] = Array
(
[id] = 1
[name] = My Gallery
[created] =
[modified] =
)
)
[1] = Array
(
[Navigator] = Array
(
[id] = 49
[parent_id] = 45
[lft] = 120
...

I'm expecting this:
$this-Navigator-generatetreelist(null, null, {n}.Navline.name,
'nbsp;nbsp;')
or $this-Navigator-generatetreelist(null, {n}.Navigator.id,
{n}.Navline.name, 'nbsp;nbsp;')
to return my tree list:
...
[30] = Products
[60] =   Journals
[68] = Gallery
[83] = On the Bench
[96] = Design, Quote, Order
[61] =   Photo Albums
[75] = Gallery
[82] = On the Bench
...

I've tried all sorts of variation and poking around... When I specify
a keypath or valuepath I get back an empty array or an array missing
the names (depending on what I specify).

Regards,
Don Drake

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

To unsubscribe, reply using remove me as the subject.


generatetreelist and conditions

2009-06-03 Thread Toutankharton

Hey everyone,

I'm trying to select all of my projects belonging to a client, but I
fail to use generatetreelist and conditions.

I tried :

$this-Project-generatetreelist(null, array('Project.client_id' =
'3'), null, null, '...');

since the second parameters seems to be the conditions in the doc... I
got this errror :

Warning (2): array_combine() expects parameter 1 to be array, null
given [CORE/cake/libs/set.php, line 972]

don't ask why, but I tried :

$this-Project-generatetreelist(array('Project.client_id' = '3'),
null, null, null, '...');

and it works, but i have all my projects at the same level :

Array
(
[32] = Project 1
[44] = Subproject 2
[11] = Project 2
)

where i should have


Array
(
[32] = 'Project 1'
[11] = 'Project 2'
[44] = '...Subproject 2'
)

any ideas ?

--~--~-~--~~~---~--~~
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 and conditions

2009-06-03 Thread brian

On Wed, Jun 3, 2009 at 8:20 AM, Toutankharton toutankhar...@gmail.com wrote:

 Hey everyone,

 I'm trying to select all of my projects belonging to a client, but I
 fail to use generatetreelist and conditions.

 I tried :

 $this-Project-generatetreelist(null, array('Project.client_id' =
 '3'), null, null, '...');


$this-Project-generatetreelist(
array('Project.client_id' = '3'),
null,
null,
'...'
);

 since the second parameters seems to be the conditions in the doc... I
 got this errror :

 Warning (2): array_combine() expects parameter 1 to be array, null
 given [CORE/cake/libs/set.php, line 972]

 don't ask why, but I tried :

 $this-Project-generatetreelist(array('Project.client_id' = '3'),
 null, null, null, '...');

 and it works, but i have all my projects at the same level :

 Array
 (
    [32] = Project 1
    [44] = Subproject 2
    [11] = Project 2
 )

 where i should have


 Array
 (
    [32] = 'Project 1'
    [11] = 'Project 2'
    [44] = '...Subproject 2'
 )


Because you have null where the '...' should be.

--~--~-~--~~~---~--~~
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 error in rc4

2008-12-24 Thread AD7six

Undefined property:  AppModel::$TicketCategory

means your TicketCategory model doesn't exist or isn't being found -
and so an instance of AppModel is used instead (since the db table
does exist).

AD
--~--~-~--~~~---~--~~
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 error in rc4

2008-12-23 Thread korcan

I have this line of code in my project that works in RC3, changed the
cake dir to the rc4 version and this happens:

my $conditions are defined before this line...
line: 326
$this-UserTicketAlert-TicketCategory-generatetreelist(array
($conditions),null, null, ''));

I moved to rc4 and I am getting:
Undefined property:  AppModel::$TicketCategory [APP/controllers/
users_controller.php, line 326]
Fatal error: Call to a member function generatetreelist() on a non-
object

any ideas?
--~--~-~--~~~---~--~~
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 error in rc4

2008-12-23 Thread Nate

Hi Korcan,

Without more information, it's hard to tell what the issue is.  Could
you paste your model files at http://bin.cakephp.org/, and post the
link back here?

Thanks.

On Dec 23, 11:28 am, korcan korcan...@gmail.com wrote:
 I have this line of code in my project that works in RC3, changed the
 cake dir to the rc4 version and this happens:

 my $conditions are defined before this line...
 line: 326
 $this-UserTicketAlert-TicketCategory-generatetreelist(array
 ($conditions),null, null, ''));

 I moved to rc4 and I am getting:
 Undefined property:  AppModel::$TicketCategory [APP/controllers/
 users_controller.php, line 326]
 Fatal error: Call to a member function generatetreelist() on a non-
 object

 any ideas?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



combinate generateTreeList and paginate

2008-09-27 Thread cyberscorp

Hi,

How can i generate a tree list with a pagination ?

Is there any combination between $this-paginate('Category') and $this-
Category-generatetreelist(null, null, null, '--')

Thank you.

Model :

class Category extends AppModel {
   var $name = Category;
   var $actsAs = array('Tree');
   var $validate = array(
'name' = array(
'rule' = array('maxLength', 255),
'required' = true,
'allowEmpty' = false,
'message' = 'Title is required.',
),
);

}

Controller :

class CategoriesController extends AppController {
var $name = 'Categories';
var $helpers = array('Html', 'Form');
var $paginate = array('limit' = 10, 'page' = 1);


function admin_index() {
if ( isset($_POST[limit]) ) $this-passedArgs['limit'] =
$_POST[limit];
$this-set('categories', $this-paginate('Category'));
$this-layout = admin;
}



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: generatetreelist()

2008-08-24 Thread validkeys

I believe that you are missing: $this-Category-create();

$this-Category-create();
$data['Category']['parent_id'] = 3;
$data['Category']['name'] = $fieldName ;
if($this-Category-save($data)){
exit;
}

I don't believe this is deprecated or is it?

On Aug 23, 12:56 pm, Abrar [EMAIL PROTECTED] wrote:
 hi , here im trying to use generatetreelist() first time,  so whats
 problem im facing is that it saves the data two times with once
 execution of code.

  here is my code that im using

         function addData($fieldName = null, $pa_id = null){

                 $existance = $this-Category-findByName($fieldName);
                 if($existance){
                 $this-set('error','This name already exists.');
                 }else{
                         $data['Category']['parent_id'] = 3;
                         $data['Category']['name'] = $fieldName ;
                         if($this-Category-save($data)){
                             exit;
                         }
                 }
         }//addData

 result in the database

        id   parent_id     lft      rght     name
 
       48        3           34       35       bari      ---
 only this result should be saved here

       47        3        NULL    NULL    bari   --- this
 is unexpected ( problem )
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



generatetreelist()

2008-08-23 Thread Abrar

hi , here im trying to use generatetreelist() first time,  so whats
problem im facing is that it saves the data two times with once
execution of code.

 here is my code that im using

function addData($fieldName = null, $pa_id = null){

$existance = $this-Category-findByName($fieldName);
if($existance){
$this-set('error','This name already exists.');
}else{
$data['Category']['parent_id'] = 3;
$data['Category']['name'] = $fieldName ;
if($this-Category-save($data)){
exit;
}
}
}//addData


result in the database

   id   parent_id lft  rght name

  483   34   35   bari  ---
only this result should be saved here

  473NULLNULLbari   --- this
is unexpected ( problem )

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: problem using TreeBehavior generateTreeList function...

2008-03-25 Thread phpcurious

my controller's code:
--
?php

class CategoriesController extends AppController {
var $name = Categories;
var $uses = array(categories);

function listcat() {
$treelist = $this-categories-generatetreelist($this-
categories,categories.id
ASC,NULL,{n}categories.id,{n}categories.description);
pr($treelist);
}


}

?
--
model's code:
--
?php

class Categories extends AppModel {

var $name = Categories;
var $actsAs = array(
Tree=array(
left=left_node,
right=right_node
)
);


}

?
-
Error shows up:
-

Warning (2): preg_match() expects parameter 2 to be string, object
given [CORE\cake\libs\model\datasources\dbo_source.php, line 1617]





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



generatetreelist

2008-02-25 Thread Mech7

Does anybody have any examples on how to use this function? I only get
a flat list back always?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---