I'm new to Zend framework and trying to get some insights about code re-usability. I definitely know about modules but there seems to be a bit of uncertainty about what functionality should go into modules and what not.
What I'm trying to accomplish:
1) to have reusable mini programs/widgets/plugins (whatever you may call them) that one can simply plug into any site be doing this in layout or view:
<?php echo $this->contactform;?>
or this in the view:
<?php echo $this->layout()->blog;?>
I'd call them extension. so basically sort of what you'd see in Joomla/ WordPress/Concrete5 templates.
2) All code that is related to that specific extension should be in it's separate directory.
3) We should be able to output extensions only for certain modules/controllers where they are required. they shouldn't be rendered needlessly if it won't be displayed.
4) each extension may output multiple content areas on the page.
Do you have a nicely laid out structure / approach that you use?
It sounds like you need study up on view helpers. View helpers can be a simple as returning the App Version number or as complicated as adding html to multiple place holders. For example:
layout.phtml:
in your view script foo.phtml for example:
Now if you want to be able to reuse that over and over again you can do this:
Now, replace the code in your foo.pthml with:
Both examples of foo.phtml output:
Hello World!
Hello World!Bar Bar!
Of course this is very simplified example, but I hope this helps point you in the right direction. Happy Hacking!