Honestly - I haven't found many resources in my own hunt for this information, but you can get a lot of inspiration to finding your solution by looking at many of the components within Zend Framework itself, particularly Zend_Form. I just made up a "Content" package that has "Element" and "Decorator" hierarchy. The elements themselves can provide their default decorators - and you can attach arbitrary decorators to them (for instance wrapping all your content boxes in <ul class='content'><li>.....</li>.....</ul>
style display on one page.
"View Helpers" become very handy, allowing you to do your "latest blog comments" style boxes by calling <?php echo $this->blogComments($article) ?>
in the view- which calls My_View_Helper_BlogComments::BlogComments()
. I definitely suggest having your own Zend_Form
subclasses as well for reusable components that happen to be forms (i.e. contact us being a "My_Form_ContactUs
" ).
The "partial" view helper comes in handy as well for abstracting certain parts of display to other reusable files. <?php echo $this->partial('blog/_comments.phtml', null, array('article'=>$article)); ?>
- There is a little more overhead used for a partial as it clones a Zend_View.
Handling the JS/CSS includes gets slightly more complicated, what I did was build a static class that you can "require" a "library" which would check to see if that library had already been included, if not - it calls headScript() / headLink() for inclusion of the required files. (used for things like FCKEditor / Sortable / jQuery / etc). Ends up looking like: My_Script::requireLibrary('fckeditor');