You can create CommentComponent.
All comments in one table: Id, ModelName,ModelId, name, email,
message...

In every controller use component with different setup, (pass Model
name and Id).
Every model HasMany Comment with criteria=>ModelName=News.
Component can catch POST data and save comment, list all commment etc.
You need only one comment element to call from News view or Video
view.



On Jan 19, 10:11 pm, Mirthis <mirt...@gmail.com> wrote:
> Hi guys!
> I'm pretty new to Cake PHP and what I find really hard, being used to
> develop PHP without following any rule or schema, is to get used to
> the MVC design.model. In this moment I'm creating stuff without any
> particular purpose in mind, but just to get confident with the
> framework and to build something I''ll be able to reuse later
> What I have in mind is pretty simple. I want a site where different
> kind of contents can be published: news, pics, videos, etc. I think
> each of them can be displayed in a different section of the site and
> so easily implemented through a controller (NewsController,
> VideosController, etc.), its model and a set of views to access
> standard operations: browse, add, edit and delete contents.
> Now I want to add a feature shared among all this controllers to let
> user add comments to a conent. All comments will have the sane info
> (username, date, text, etc.) and should be displayed and managed in
> the same way regardless of the section where they're posted. It sounds
> simple but I have no idea on how to design it following MVC
> principles.
>
> Model
> I was thinking of having a unique table for all the comments and a set
> of associatives tables, one for each type of contents, to store
> association between a comment and a content item. Is not the best
> approach if we think about performance, so an alternative could be to
> have separate commments tables to speed up filtering. Anyway is not my
> first concern now.
>
> Controller
> I have two idea on how to implement the basic actions, but none of
> them looks right to me. The first is to have a comments controller
> class implementing the actions and then to create a set of subclasses,
> one for each type of contents, so I would have NewsCommentsController,
> VideosCommentsController, etc. In the subclasses I'd declare the right
> instance of the Model and call the superclass actions. The other idea
> is to have a component implementing the shared functionalities, but
> I've no idea if it's the right way to use a component and on how to do
> it.
>
> View
> I figure out I should have at least a view (or maybe an element?) to
> add a comment and one to show them, and that's all.
>
> A part from this what I can't understand well is how to put together
> all the pieces to obtain the final result. For instance having a main
> controller and its view, for example showing news, how can I add the
> action for posting/showing comments (that are in a different
> controller or component) and it's related view in the same page?
> U hope someone can give me some wise tips.And if someone is not clear,
> pleas ask me, I'm not a native english speaker and so I do lot of
> confusion some times.
> Thanks;)
>
> Andrea
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to