In your opinion, when using the Zend Framework is it bad practice to have a view script with out an associated action?
I ask because in my Zend Framework app I use some view scrips that do not have an action associated with them. (Similar to the example on page 102 in the Zend开发者_开发百科 Pro Framework Techniques book http://books.google.com/books?id=znA1LgQSxsoC&lpg=PP1&dq=Pro%20Zend%20Framework%20Techniques%3A%20Build%20a%20Full%20CMS%20Project&pg=PP1#v=onepage&q&f=false) and because Zend_Tool does not allow you to create an view inside of a module(as far as I can tell).... it will create a view in side a module only if you use
zf create action name controller-name[=Index] view-included[=1] module
Any thoughts on this would be appreciated.
Are you creating "partial" view scripts? A partial view script is a view script that helps you reuse code in multiple view scripts. They are commonly named with an underscore to signify that they are a partial view script. It's perfectly acceptable to have a partial view script without a controller action.
/posts/index.phtml
/posts/show.phtml
/posts/_post.phtml
# index.phtml
foreach ($this->posts as $post) {
echo $this->partial('posts/_post.phtml', array('post'=>$post));
}
# show.phtml
echo $this->partial('posts/_post.phtml', array('post'=>$post));
# _post.phtml
<h1><?php echo $this->post->title ?></h1>
<p><?php echo $this->post->body ?></p>
精彩评论