这是帖子/ index.php文件=>CakePHP问题:如何从另一个控制器调用一个控制器的视图?
<?php foreach ($allposts as $post) {
echo '<tr class="class_row">';
echo '<td>';
echo $this->Html->link($post['Post']['title'],
array('controller'=>'posts','action'=>'view',$post['Post']['id']),
array('id'=>'id_anchor_title','class'=>'class_anchor_title'));
echo '<tr>';
echo '<td>';
}
?>
我想打电话从产品/ index.ctp =>这个帖子/ index.ctp这将是所有控制器的通用/通用index.ctp。我怎样才能做到这一点 ?
在posts/index.ctp中使用$ allposts。它在帖子/索引操作中设置。但是当我从产品/索引行动中调用posts/index.ctp时,不同的变量就设置在那里。假设$ this-> set('allproducts',$ allproducts);在产品/索引行动中设置。现在我怎么能使用posts/index.ctp中的所有产品变量?
+1它为我工作,谢谢。 – Chinmay235