0
我有2次,postview.ctp和usercomment.ctp,調用相同comment.ctp元素。該元素使用UploadPack助手顯示圖像。但在usercomment.ctp圖像不顯示,有此錯誤消息
Notice (8): Undefined index: User [APP\Plugin\upload_pack\Model\Behavior\UploadBehavior.php, line 222]
line 222: $settings = self::$__settings[$modelName][$field];
自:: $ __設置在usercomment.ctp是空的,但在postview.ctp它不是空的,圖像正確顯示。
comment.ctp:
<?php echo $this->Html->link($this->upload->image(
$comment['User'],
'User.avatar',
array('style' => 'thumb'),
array('class' => array('img-responsive', 'img-rounded'))
),
array('controller' => 'users',
'action' => 'view',
$comment['User']['id']),
array('escape' => false)
) ?>
這是代碼來調用comment.ctp從兩個視圖。
<?php if (!empty($comments)): ?>
<?php foreach ($comments as $comment): ?>
<?php echo $this->element('comment',array('comment' => $comment));?>
<?php endforeach; ?>
<?php endif; ?>
我檢查了$ comment數組,它們是相同的。如何解決它?