Jump to content

[Zend] - $this in different phtml page


TFT2012

Recommended Posts

Hi, I have a newbie question again here.

Now I am really confused with $this in each phtml page. Like, I have a IndexController.php in controller folder, then correspondingly, will have a index folder underneath the view->scripts folder. Then inside the views->scripts->index folder, each phtml file, the $this will refer to the IndexController object. Am I right?

 

If I am correct above, then Zend wants us to use layout. For application->layouts->scripts folder, I create a phtml file named main.phtml ( follow the Zend quickstart guide ). Inside the main.phtml, it contains $this too, like $this->layout()->content. There is no such a controller like xxxxController for layout, I am wondering which object this $this refers to? Why can it invoke layout() and content, where do these two come from?

I only thing did for layout was adding "resources.layout.layoutpath = " in Bootstrap.ini.

 

Please help, thanks!

Link to post
Share on other sites

IIRC a layout is essentially a template for views to fill in. So $this would be the view being executed.

 

If you're not sure, print_r() it and see exactly what it is.

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.