This PHPMaker 2024 project will show you how to display all the Comments hierarchically using Closure Table.

To simplify the logic how to display all the Comments, then we can create a PHP function that will call itself (recursive function). You will learn how to make it works with only by 2 tables! First table to store the Comments, and the other for storing the tree paths of Comments, which is called by Comments Closure.

You may add a new Comment, add a Reply to Comment, move a Comment, move a Comment as a New Top Comment, move a Comment under another Top Comment, edit a Comment, and remove a Comment. The moving and removing operations will include all its Descendants (if any).

We can also manage some possibilities such as, whether a Comment can be moved to another Ancestor or not, whether a Comment should be prevented to be moved to its Descendant, since its position is now as a Top Comment, or a Comment cannot be moved below its Descendant since it will break the rule of a hierarchical structure.

You will learn a lots of thing about how to implement Closure Table so ease by using PHPMaker. Instead of writing code from scratch, we just need to write a few lines of code from Server Events of PHPMaker project!

You will know also that as a matter of fact, to implement all those things I mentioned above, we just need to create some Views inside the MySQL database. Then we can simply use some functionalities from it via a Custom File.

Last but not least, you will also learn how to use Custom File in PHPMaker project in order to reset or empty the tables, including to restore data samples from SQL files. This is very useful if you want to provide some data sample in your web application for your End-Users by simply clicking some menu items.