I know the term Widget is a loaded concept, but was wondering what
everyone's thoughts on the best way to create reusable
Controls/Components/Widgets.
To me a Widget is something you can drop into any controller and it
would be able to handle rendering itself and working with Model. At
first this sounds very similar to a View Helper, which is how I have
done this so far. The issue comes when you need to update the Model.
Updating a model from the view is not really good practice or allowed in
MVC.
An example situation, may help paint the picture:
A Widget photo selection widget. This widget would fetch images
from some Gallery Model. The view part of the widget would show a
thumbnail grid of the photos, with some sort of js lightbox modal.
When a user select one photo, it would via ajax, post back and add
to the image to his favorite photos collection, which means we need
to update a model.
If this widget was just going to be in one system, you would just create
a view helper, and the controller to handle the ajax. If you want to
make this ajax/post reusable you could create an Action Helper. So to
me seems like to be able to do this, you would need a way to create an
encapsulate package that includes a View Helper and Action Helper.
What we want to be able to do, similar to modules, is to just drop a
widget in place. It doesn't need to go as far as having to bootstrap
itself like a module. It can work like action helper / view helpers do
with brokers. The issue I have is that since the package is contained,
you are going to add up with a bunch of helper paths which is going to
really hurt performance if you have a bunch of widgets in your system.
Thoughts? Ideas? I am thinking too much about this :)