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 '<ul>';
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
> <[email protected]<javascript:>
> > 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 <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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> 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 [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.