大家好我试图访问每个单独用户的配置文件图片文件名,当他们登录到系统。我有一个'配置文件'表,我需要在我的default.ctp视图文件中提供,因为我正在尝试加载配置文件映像。如何访问配置文件模型文件名字段以显示每个用户配置文件图片
我目前使用$ current_user变量设置在我的appController的beforefilter中,以$ current_user ['filename']的形式访问'users'。我的用户和配置文件关系已在我的模型中相应设置。如果任何人都可以帮助,我将不胜感激。提前致谢。
我AppController中的beforeFilter声明:
$this->loadModel('Profile');
$profiles = $this->Profile->find('all');
$this->set('profiles', $profiles);
我default.thtml中查看文件代码尝试:
<?php echo $this->Html->image('/uploads/profile/filename/thumb/small/'.$profile['filename']); ?>
当前代码:
<?php echo $this->Html->image('/uploads/profile/filename/thumb/small/'.$current_user['filename']); ?>
我需要能够访问当前用户的配置文件模型文件名字段,以显示其已经b的图片een保存到文件名字段。它会在用户登录时调用,并且我想显示这个用户个人资料图片。
在default.ctp视图中,Iam使用下面的代码,但我需要针对每个用户个人资料图片进行调整。
foreach($profiles as $profile) :
echo $current_user['Profile']['filename'];
endforeach
;
感谢shoesole我将在今后的记住这一点。我已经测试过你的方法,它的功能就像一个魅力。谢谢。 – Joshua