Hi, I’m trying to set data from a table to default.ctp. So in AppController.php, I added:
public function beforeFilter(Event $event) { $usersTable = TableRegistry::get('Users'); $users = $usersTable->getAllUsers(); $this->set('users', $users); }
And in default.ctp:
<?php foreach($users as $user){ echo $user['first_name']; } ?>
But apparently $users was not set. I also tried adding this in PagesController.php but I got a blank screen after doing so:
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
}
I need some help to figure out what I’m missing, any help would be greatly appreciated. Thanks!