Identify the variable in my .ctp file

Hello Everyone,

I’m very new to CakePHP and I’m trying to learn things quickly but I’m stuck what seems to be a very simple thing but has been difficult to figure out for me personally.
I have a .ctp file and it is using a line : <?php echo $body_class; ?>
I’m not able to understand which file is this var $body_class coming from?

Please bear with me if the question sounds too naive or basic and redirect me to the right channel to look for it.

probably Controller action passing the variable to this ctp view

Something like this

public function index()
    $body_class = 'my-class-string';
    $this->set('body_class', $body_class);

View index.ctp:


I searched in the controller file but it is not found there :confused:

if its not from Controller search in AppController or Layouts/default.ctp view
debug($body_class) has value?

Ok. Looks like the value being assigned to the $body_class var is coming from url params.
Thanks for the help!

Sometimes vars can come from beforeRender() in the current Controller or the beforeRender() in AppController or Components.

Tried it, with no success!

Have you try fix controller, there should be something broken.

bazy maili firm

I didn’t find anything wrong with the controller but I was not understanding the flow of control for the variable.