Cakephp Szajbus uploadpack - 图像不显示,因为 self::$__settings 数组为空



我有 2 个视图,postview.ctp 和 usercomment.ctp,调用相同的 comment.ctp 元素。此元素使用上传包帮助程序显示图像。但是usercomment.ctp上的图像没有显示并且有此错误消息

Notice (8): Undefined index: User [APPPluginupload_packModelBehaviorUploadBehavior.php, line 222] 
line 222: $settings = self::$__settings[$modelName][$field];

usercomment.ctp 中的 self::$__settings 为空,但在 postview.ctp 中它不为空,图像显示正确。

评论.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数组,它们是相同的。如何解决?

在注释控制器中的用户注释操作上加载用户模型。

public function usercomments($id) {
    $this->loadModel('User');
    if($this->Auth->loggedIn()){
    .....

最新更新