I am trying to set a variable in my controller so that I can reference it in a view file
Here is an example of a successful set statement from the same action/function
//users_controller.php, index() function $this->set('bidBalance', $this->Membership->User->Point->balance($this->Auth->user('id'), true)); With the above, in my index.ctp file I can display the result by:
print($bidBalance); So I have to get some other data back to the view so I do the following:
$this->set('nextMembership', $this->Membership->find('first', array('conditions' => array('Membership.rank >' => $membership['Membership']['rank']), 'contain' => '', 'order' => array('Membership.rank' => 'asc')))); And when I try to access $nextMembership in my view file I get a notice:
Notice (8): Undefined variable: nextMembership [APP/views/themed/users/index.ctp, line 138 The thing is the query I assign to 'nextMembership' is used elsewhere and successfully returns data so I am not sure what is wrong.
Also, for my sanity's sake I even tried
$this->set('nextMembership', 'hello world'); But I still get the undefined notice.
What am I doing wrong?