how to reach database fields from default.ctp in Cakephp -



how to reach database fields from default.ctp in Cakephp -

i'm unable show db field value in default.ctp , unreaded messages or username , maintain getting undefined variable: user, or message

how reach them default.ctp ?

since default layout application wide, need process info in appcontroller.php in beforefilter method, this

in appcontroller.php :

public function beforefilter() { //for example, want read messages //import model $this->loadmodel('message'); $all_messages = $this->message->find('all'); //or whatever need info $this->set('all_messages', $all_messages); }

then in default.ctp,call variable: $all_messages

cakephp

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -