Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-27-2008, 06:21 PM
Junior Member
 
Join Date: Apr 2008
Posts: 2
Default Adding a constructor to the controller

Hey guys, I wrote an MVC framework a while back but I am migrating to Zend.

One of the things I used to do is have a constructer in my controllers in which I could write code that applies to all the actions within the controller.

For example...

the Account controller would have a lockout function within the constructor. Unstead of locking out each action individually.

Any thoughts on this?

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-27-2008, 06:58 PM
Piro's Avatar
Junior Member
 
Join Date: Apr 2008
Location: Holland
Posts: 8
Default

In ZF you can use the init() function in your controller. For example:

PHP Code:
    public function init()
    {
        
$this->_helper->layout->setLayout('shop');
    } 
This will let the complete controller use the 'shop.phtml' layout file instead of 'layout.phtml'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:22 AM.