Hi all I have a ‘profiles’ table and I need to make this available in my default.ctp view file as I am trying to load profile images. I currently use the $current_user to access the ‘users’ in the form $current_user[‘filename’]. My user and profile relationships have been set in my models accordingly. If anyone could help I would appreciate it. Thanks in advance.
My AppController’s beforeFilter declaration attempt:
$this->set('profile', $this->loadModel('Profile'));
$this->set('profile', $this->User->find('all'));
My default.ctp view file code attempt:
<?php echo $this->Html->image('/uploads/profile/filename/thumb/small/'.$profile['filename']); ?>
Current code:
<?php echo $this->Html->image('/uploads/profile/filename/thumb/small/'.$current_user['filename']); ?>
You should clarify your requirements. If you want all profiles information on every page, then this is what you need:
but you should specify exactly what data you want to return (
id,filename), as otherwise you will be returning huge amounts of data on each request, which will kill performance at any real level.You should cache this query and the result as it will likely not change very often.
Edit: consider whether to use
beforeFilterorbeforeRender, depending on your needs.