【发布时间】:2011-09-07 15:05:41
【问题描述】:
这是帖子/index.php =>
<?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>';
}
?>
我想从 products/index.ctp 中调用这个 posts/index.ctp => 这将是所有控制器的通用/通用 index.ctp。我该怎么做?
在posts/index.ctp 中使用了$allposts。它在帖子/索引操作中设置。但是当我从 products/index 操作中调用 posts/index.ctp 时,会在那里设置不同的变量。假设 $this->set('allproducts',$allproducts);在产品/索引操作中设置。现在我如何在 posts/index.ctp 中使用 allproducts 变量?
【问题讨论】:
标签: cakephp cakephp-1.3