I’d like to set the layout’s $scripts_for_layout from within the controller.
Is this possible, and if yes how?
I’d like to set the layout’s $scripts_for_layout from within the controller. Is this possible,
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.
Short answer: maybe you’re doing it wrong.
Long answer: Scripts should not be controller dependent. It’s ‘theoretically’ wrong, and cake does not like people who doesn’t adhere to the mvc pattern.
Workaround (because sometimes you just need to): You can set in beforeRender a var:
And in the layout check for $scripts and add them.