My question needs a bit of setup, so please bear with me:
I became a convert to using View Helpers for getting data from a model rather than sprinkling it all over the controllers (hat tip to Eric Clemmons). It's much more reusable and flexible there. I just love it!
What I usually do, is lay out the template in the index.phtml, and then when I need to get something from a model, put that snippet in a detail.phtml, so logic is as far out of the way as possible.
However, I start to see the need for variables that get reused. For example, the category name. Now you don't want to use a view helper to get the cat name from a model over and over again. Although you can cache it, it's obviously way too big of a hassle.
So I started using a couple of lines of php in the detail.phtml to set variables. And it doesn't smell right anymore. Views shouldn't have too much logic.
So what say you all? If the var gets reused, put it in the controller? Or don't mind a couple vars set in the view?
EDIT: Alan Storm asked for an example of viewhelpers:
detail.phtml:
<ul id="productList">
<? foreach($this->getProductById($id) as $product) : ?>
<li><?= $this->escape($product['name']) ?></li>
<? endforeach; ?>
</ul>
(bracing myself for attack of the anti-short-taggers)
ANOTHER EDIT: I see there can't be 2 right answers. Oh well...