Comments hierarchy

Hell CakePHP devs, looks like we finally have version 5.0.0 stable… Really thrilled!

Anyway are there more convenient approaches to deal with Comments hierarchy in CakePHP than using ‘Tree behavior’… I’m trying with ‘Tree behavior’ and it seems fine in the model side, but couldn’t find a proper way to bring it to the template side.

Depends on how deep you wanna go with comments. If comments can have their own comments then sure it can be implemented via a tree structure.

You can also do your own parent-child implementation if you want to.
Basically 1 parent Comment can have many child comments and each child comment belongs to 1 parent comment. And by default the parent_id is 0 or null (depends on how you want to implement it) for “first layer comments”

See also the ->find('threaded') in Retrieving Data & Results Sets - 4.x

2 Likes