Building a Layout in Zend framework

Hello everyone! Recently started getting acquainted with ZF and started writing the first project on it!

There was a question like this:

Building the main page of the site. The task is to make a site in 2 columns, in the left content is displayed by indexContoller‘om, in the right column is an authorization form and, say, 5 latest news …

How to implement this? Is it really possible to shove everything into one controller and display it like $this->layout()->content???

My thoughts are that maybe there is some kind of view helper that, for example, can insert the result of another controller into the layout is acceptable:

<div class="leftbar">
    <?=$this->layout()->content;?>
</div>
<div class="rightbar">
    <?=$this->layout()->viewHelper('controller', 'action');?> /*   */
</div>

Something like that! Does this exist in zf or is it implemented differently?

Question two (if I think correctly in the first question): how to load different layouts for different controllers??? I already know for modules, but I can’t think of anything for controllers …

public  function preDispatch()
{
    $bootstrap = $this -> getActionController()
    -> getInvokeArg('bootstrap');
    $config    = $bootstrap -> getOptions();
    $module    = $this -> getRequest()
    -> getControllerName();
    //        
    if(isset($layout){  
        $layoutScript = $layout;
        $this -> getActionController()
        -> getHelper('layout')
        -> setLayout($layoutScript);
    }
}

My config is in .ini. Can I somehow write layouts for different controllers in it?

In general, I ask for help! Thank you all in advance!


Answer 1, authority 100%

don’t use shot tags to start with, use it normally <?php ?>

https://softwareengineering.stackexchange.com /questions/151661/is-it-bad-practice-to-use-tag-in-php

As for your question, I recommend not using layout. or you can make the content what it is, and connect the authorization form to the right column and pull out the latest 5 news from the database. On the left, the content will change, and on the right, the authorization will be constantly visible.
it will be just necessary to specify the output agent of the form in a zendovsky form.
religion does not forbid you to display the form
an example would be like this

<div class="leftbar">
    <?php $this->layout()->content;?>
</div>
<div class="rightbar">
    <?php $form = new Application_Form_Temp();
       echo $form;/*/
   echo Zend_DB_Select()->select()->from('news')->order('timecreate desc')->limit('5');?>
</div>

but how bad it is for me to pull it from the base into layout. will load the site
. with Optimization, think about it, but my idea is this.