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  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: 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


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: 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.


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



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



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