Re: Multi-level menu with Modified Preorder Tree Traversal

2014-04-07 Thread Marco Sbragi
You can find more info here:
Scroll down to "Finding the Depth of the Nodes"
http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

Il giorno martedì 8 aprile 2014 08:19:40 UTC+2, Marco Sbragi ha scritto:
>
> Hi Sam,
> I don't have time to make test at this moment, and sincerely i think 
> recursion is the best method to make this work.
> I can tell you of a solution i found time ago with cake 1.0 in one of my 
> application.
> The base of the logic is in the query i wrote (the query is simplified i 
> write here only the significant fields):
> Don't know if it is correct but i think that shows the sense of this 
> approach.
>
> SELECT node.lft, node.rgt, node.id, node.parent_id, 
> (COUNT(parent.parent_id) - 1) AS depth,
>node.description, node.link FROM menu AS node, menu AS parent
>WHERE node.lft BETWEEN parent.lft AND parent.rgt;
>
> this query return a flat list with a depth field that is the hierarchical 
> level of indentantion of the item (node).
> Then at every change of depth up or down you can write the corresponding 
>  or 
> This is a logic i used many years ago, whit cake 1.0 at this time with the 
> new features of cakephp i would never use this method.
> HTH
>
> Il giorno domenica 6 aprile 2014 21:13:39 UTC+2, Sam Clauw ha scritto:
>>
>> Hi Marco, thanks 4 your answer too! I realy do appreciate those great 
>> scripts you're sending to me. But right now, I still got the problem that I 
>> can't write the essence of a multi-level menu (without recursion) on my own 
>> ;)
>> Perhaps, you can tell me if / how I can cross my tree-based database 
>> table and output it in a realy simple  list? No active class of 
>> whatever, but the real essence would help me a lot! :)
>>
>

-- 
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: Multi-level menu with Modified Preorder Tree Traversal

2014-04-07 Thread Marco Sbragi
Hi Sam,
I don't have time to make test at this moment, and sincerely i think 
recursion is the best method to make this work.
I can tell you of a solution i found time ago with cake 1.0 in one of my 
application.
The base of the logic is in the query i wrote (the query is simplified i 
write here only the significant fields):
Don't know if it is correct but i think that shows the sense of this 
approach.

SELECT node.lft, node.rgt, node.id, node.parent_id, 
(COUNT(parent.parent_id) - 1) AS depth,
   node.description, node.link FROM menu AS node, menu AS parent
   WHERE node.lft BETWEEN parent.lft AND parent.rgt;

this query return a flat list with a depth field that is the hierarchical 
level of indentantion of the item (node).
Then at every change of depth up or down you can write the corresponding 
 or 
This is a logic i used many years ago, whit cake 1.0 at this time with the 
new features of cakephp i would never use this method.
HTH

Il giorno domenica 6 aprile 2014 21:13:39 UTC+2, Sam Clauw ha scritto:
>
> Hi Marco, thanks 4 your answer too! I realy do appreciate those great 
> scripts you're sending to me. But right now, I still got the problem that I 
> can't write the essence of a multi-level menu (without recursion) on my own 
> ;)
> Perhaps, you can tell me if / how I can cross my tree-based database table 
> and output it in a realy simple  list? No active class of whatever, 
> but the real essence would help me a lot! :)
>

-- 
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: Multi-level menu with Modified Preorder Tree Traversal

2014-04-07 Thread Marco Sbragi
Hi Sam,
I don't have time to make test at this moment, and sincerely i think 
recursion is the best method to make this work.
I can tell you of a solution i found time ago with cake 1.0 in one of my 
application.
The base of the logic is in the query i wrote (the query is simplified i 
write here only the significant fields):

SELECT node.lft, node.rgt, node.id, node.parent_id, 
(COUNT(parent.parent_id) - 1) AS depth,
   node.description, node.link FROM menu AS node, menu AS parent
   WHERE node.lft BETWEEN parent.lft AND parent.rgt;

this query return a flat list with a depth field that is the level of 
indentantion of the item (node).
I think something like this can do the work:

$depth = $items['Node'][0]['depth'];
echo '';
foreach( $items as $k => $item ) {

}



Il giorno lunedì 7 aprile 2014 14:44:52 UTC+2, Jacob Stevens ha scritto:
>
> This is a great article, but doesn't have a lot to do with CakePHP. It 
> certainly spells it out clearly though, and the examples are in PHP.
>
> http://www.sitepoint.com/hierarchical-data-database/
>
>
>
>
> On Sun, Apr 6, 2014 at 3:13 PM, Sam Clauw 
> 
> > wrote:
>
>> Hi Marco, thanks 4 your answer too! I realy do appreciate those great 
>> scripts you're sending to me. But right now, I still got the problem that I 
>> can't write the essence of a multi-level menu (without recursion) on my own 
>> ;)
>> Perhaps, you can tell me if / how I can cross my tree-based database 
>> table and output it in a realy simple  list? No active class of 
>> whatever, but the real essence would help me a lot! :)
>>  
>> -- 
>> 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+u...@googlegroups.com .
>> To post to this group, send email to cake...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/cake-php.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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: Multi-level menu with Modified Preorder Tree Traversal

2014-04-07 Thread Jake
This is a great article, but doesn't have a lot to do with CakePHP. It
certainly spells it out clearly though, and the examples are in PHP.

http://www.sitepoint.com/hierarchical-data-database/




On Sun, Apr 6, 2014 at 3:13 PM, Sam Clauw  wrote:

> Hi Marco, thanks 4 your answer too! I realy do appreciate those great
> scripts you're sending to me. But right now, I still got the problem that I
> can't write the essence of a multi-level menu (without recursion) on my own
> ;)
> Perhaps, you can tell me if / how I can cross my tree-based database table
> and output it in a realy simple  list? No active class of whatever,
> but the real essence would help me a lot! :)
>
> --
> 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.
>

-- 
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: Multi-level menu with Modified Preorder Tree Traversal

2014-04-06 Thread Sam Clauw
Hi Marco, thanks 4 your answer too! I realy do appreciate those great 
scripts you're sending to me. But right now, I still got the problem that I 
can't write the essence of a multi-level menu (without recursion) on my own 
;)
Perhaps, you can tell me if / how I can cross my tree-based database table 
and output it in a realy simple  list? No active class of whatever, 
but the real essence would help me a lot! :)

-- 
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: Multi-level menu with Modified Preorder Tree Traversal

2014-04-01 Thread Marco Sbragi
Hi Sam, this is a component and  helper i forked on github for this 
purpouse.
my implementation is written to work with bootstrap 2.3 and SQLite but 
originally was achieved to work with superfish
https://github.com/msbragi/cakemenu

Original fork

https://github.com/spiliot/cakemenu

Actually i have rewritten the code to work with bootstrap3 and font 
awesome4 but not updated the repository
HTH

Il giorno lunedì 31 marzo 2014 18:16:17 UTC+2, Sam Clauw ha scritto:
>
> Hi all,
>
> In this  well 
> known example, the indention of the levels is done by some  's instead 
> of 's.
> I wonder if there's a way to use MPPT (Modified Preorder Tree Traversal) 
> logic to dynamically build those multi-level menu without using any 
> recursion?  I can't figure out where I have to close those 's and 
> 's... :s
>
> Thx!
>

-- 
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: Multi-level menu with Modified Preorder Tree Traversal

2014-04-01 Thread euromark
right.. :)

Am Dienstag, 1. April 2014 13:04:44 UTC+2 schrieb Sam Clauw:
>
> Hi euromark,
>
> I did noticed your article, but I don't want to put the whole Tools plugin 
> into my system...
> In fact, the most important thing is that I can code such a tree by myself 
> (and with soms exterial forum help of course) ;)
>

-- 
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: Multi-level menu with Modified Preorder Tree Traversal

2014-04-01 Thread Sam Clauw
Hi euromark,

I did noticed your article, but I don't want to put the whole Tools plugin 
into my system...
In fact, the most important thing is that I can code such a tree by myself 
(and with soms exterial forum help of course) ;)

-- 
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: Multi-level menu with Modified Preorder Tree Traversal

2014-04-01 Thread euromark
Did you 
see http://www.dereuromark.de/2013/02/17/cakephp-and-tree-structures/ ?


Am Montag, 31. März 2014 18:16:17 UTC+2 schrieb Sam Clauw:
>
> Hi all,
>
> In this  well 
> known example, the indention of the levels is done by some  's instead 
> of 's.
> I wonder if there's a way to use MPPT (Modified Preorder Tree Traversal) 
> logic to dynamically build those multi-level menu without using any 
> recursion?  I can't figure out where I have to close those 's and 
> 's... :s
>
> Thx!
>

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