views:

37

answers:

1

Creating custom Zend View helpers I often end up with something like:

// logic here
if ($condition) {
    $output = <<<EOS...
} else {
    $output = <<<EOS...
}

or using switch.

Then to eliminate this, I create setPartial(), getPartial() and htmlize() for using external .phtml's.

This is not the best solution, because partials do not support doctype changing.

  • Is there any better solution, than creating abstract class handling this common case?
  • Are there any ready Zend solutions for this case?
  • Separate view helper for each case? And where to put common code?
A: 

I have ended up with view helpers (using services) and rendering the partials inside helpers.

There is an option to have logic in partials too, but in the long run. this is not the best solution.

takeshin