views:

13

answers:

1

Hello, I have a few widgets I need to show on a site - they are all relating to different types of data (e.g user, house). Each type of data and its relations is represented in specific models, but as far as a controller or helper is concerned, is it an ok plan to have a generic Widget controller/helper which generates the necessary widgets, even though each widget is dealing with distinct data? I don't really want to generate these widgets within the User and House controllers, as these controllers are dealing with different types of functionality.

I'd imagine that the Widget_Controller could just contain static methods for generating these widgets, e.g: Widget_Controller::user_panel();

Does that make sense? Cheers!

A: 

I am not sure I understand what you are trying to do. If you have MVC architecture and you are trying to create reusable components, which have some internal data (models) and some presentation (views), you just create a generic controller with associated views and models. So if you often create tables with CRUD functionality, you can create views for the CRUD and for the table, create controller with e.g. sorting functionality and links to the CRUD actions and you can include bindings to general model properties, which can be arguments for sorting or used to choose columns to be included in the table. Does this help a bit?

Gabriel Ščerbák