As far as best practices go is this recommended? I have a comments controller + model that needs to be called in an items and profiles controller. The comments controller automatically loads the comments model.
Is it acceptable to call the comments controller directly from the items and profile controller, or is the “best practice” way to call the comments model instead?
I ask because in kohana, the view isn’t a singleton class so if I were to call a controller within another controller I end up with two views. On the other hand, if I were to just call the model, there would be duplicate code within the items and profiles controller.
All you MVC experts help! =)
Generally, I’d go for the “Fat Model” approach.
I’m not sure what code you’re really worried about duplicating.
There are a couple ways you could do this:
First way:
– Interrogate your Comments model to return some comments.
– Pass the comment data into your view.
– Render the comments in the view, possibly using some view helper
Second Way:
– Realize that there’s no reason your view can’t talk directly to your model.
– Write a view helper that grabs the data it needs directly from the model, and renders it.
I prefer the second way. Some people have a problem letting their view layer talk to the model (in a read-only fashion!), but I’m not one of them.