我遍歷一組同類產品CakePHP的:調用元素
<?php foreach ($results as $result): ?>
<?php echo $this->element('result_item', array('product', $result)); ?>
<?php endforeach; ?>
這裏時,無法設置一個變量是我的元素代碼的摘錄:
[...]
<?php echo $this->Html->url(array('controller' => 'view', 'action' => 'index', $product['Product']['product_slug'])) ?>
[...]
我得到以下錯誤,每個我嘗試訪問$ product
Notice (8): Undefined variable: product [APP/View/Elements/result_item.ctp, line 2]/view">
我在做什麼錯?
請爲清晰起見添加元素和控制器代碼。 – Anubhav