Ok, so you can't pass objects to partials (unless they can be converted to an
array). So, what alternatives do you have/suggest for being able to pass
objects (in this case Doctrine Entities/Models) to something like a partial
so that you can add markup to a .phtml file?
I guess what I'm wanting is a cleaner approach for handling some (somewhat)
complex markup that could be accessed/used from different places in the
system.
I realize that I could use a view helper, but you end up having to return
your formatted markup and it just isn't as clean:
class PrintTopic extends Zend_View_Helper_Abstract
function printTopic(Model_Topic $topic)
{
$html = '<div>' . $topic->getDescription() . '</div>';
// Do some other stuff based on $topic
return $html;
}
I'd prefer to be able to do something like this:
topic.phtml
<div>
<?= $topic->getDescription(); ?>
<!-- other stuff -->
</div>
So that I could end up doing something like this in my view
<ol>
<?php foreach ($this->topics as $topic): ?>
<li><?= $this->partial('topic.phtml',$topic) ?></li>
<?php endforeach; ?>
</ol>
I hope that this makes sense, let me know if I need to explain better.
There also may be a better way to doing what I'm asking, so feel free to
offer up any suggestions.
--
View this message in context:
http://n4.nabble.com/Passing-objects-to-partials-alternative-approaches-tp1745997p1745997.html
Sent from the Zend Framework mailing list archive at Nabble.com.