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 > <ul> or </ul> > 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 <ul><li> 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
