如何使用渲染将变量从一个视图传递到另一个视图

How to pass variable from one view to another using render

在一个视图中 kat.phtml 我有变量 $i,我想在另一个视图 opinia.phtml 中使用这个 $i。如何传递这个 $i ?

<?php for ($i = 0; $i < count($this->allProd); $i++) : ?>
   <?php echo $this->render('oferta/opinia.phtml'); ?>
<?php endif ;?>

您应该使用 partial - 然后您可以传递额外的变量:

$this->partial('oferta/opinia.phtml', array('i' => $i));