TFT2012 Posted July 27, 2012 Share Posted July 27, 2012 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! Quote Link to comment https://forums.phpfreaks.com/topic/266344-zend-this-in-different-phtml-page/ Share on other sites More sharing options...
requinix Posted July 27, 2012 Share Posted July 27, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266344-zend-this-in-different-phtml-page/#findComment-1364945 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.