I have variables in each controller, and I have been passing them to the view with $this->set for every function. It’s repetitive. How can I simply refer to the object that renders the view and thus refer to its variable?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use your beforeFilter or beforeRender. So if you have the same set of variables you need to set for every function, just add this to the top of your controller:
UPDATE: Thanks for bringing that to my attention. You are correct. I added
$thisto the variables.