I’m using cakephp, I have a model “comment” with two fields : “model_type” and “model_id” in order to comment every item of my application (eg Picture, News, Article, …) with a single Comment model.
I wonder how to make this. (A component “Comment” for controller that could be commented ?)
Finally I want to list comment in view just with a helper:
$comment->show(‘model_name’, ‘item_id’);
that would display correctly paginated comments and a form for adding a new comment to the item.
Thanks.
Edit: See this too : http://bakery.cakephp.org/articles/AD7six/2008/03/13/polymorphic-behavior
The Solution
A multi model commenting system and pagination just with :
The model
Scheme :
The Comment Model :
The Controller
The views
Comments element
Comment element