Zend Framework: Render multiple Views in one Layout

前端 未结 4 1031
终归单人心
终归单人心 2020-12-24 09:37

I want to generate a dynamic site using Zend_Layout.

My layout (/application/layouts/scripts/layout.phtml) contains the following lines:

...        
         


        
4条回答
  •  一向
    一向 (楼主)
    2020-12-24 10:26

    I would also advise against using the action view helper. Unless you have a bunch of logic in your controller, you probably don't need to dispatch another request to another controller just to render a view partial.

    I would recommend simply using a view partial just like you have done with your header.phtml and footer.phtml:

    
    
            render('header.phtml') ?>
    
            
    layout()->content ?>
    render('auth/login.phtml') ?>
    render('footer.phtml') ?>

    And maybe your auth/login.phtml view script looks like this:

    user)): ?> Please log in Hello user->name ?>

    As long as you set your view variables at some point in your controller, you can call the render view helper from within a view (or even a controller if you wanted to).

    #index controller
    public function indexAction()
    {
        $this->view->user = Model_User::getUserFromSession();
    }
    

提交回复
热议问题