[Solar-talk] Composite views
Rodrigo Moraes
rodrigo.moraes at gmail.com
Fri Nov 2 18:19:58 CDT 2007
On Nov 2, 2007 8:55 PM, Paul M Jones wrote:
> Or do you maybe mean a 2-step view, or partials?
I've been using something to have some kind of components or gadgets
"detached" from a controller/view. It is a mix of view and controller
helpers, and the best to explain is to use an example. In a view, I
call:
<?php echo $this->widget('News')->latestNews(); ?>
* 'widget' is a view helper that just returns a "factory" controller helper.
* the controller helper builds the 'News' object, sets the view and
page controller as a property of it, and returns it.
(at this point, the News object has access to public controller
properties - plus controller helpers - and has a view object to work
with)
* 'latestNews' fetches some data from a model and returns the result
using partials.
* the view template paths are unset and set back to original before
and after 'latestNews', so that 'News' can use its own template
directories stored relatively to it.
The prize: I can call the 'latestNews' box in any controller. It is
independent and takes care of everything it needs (data, templates).
Now, what do you guys think? Is this too much overhead? What other
tricks could we use to have this "modularity"?
-- rodrigo
More information about the Solar-talk
mailing list