1

I'm trying to add a view of another module in my layout, so I did this:

$layoutTestdrive = new ViewModel();
$layoutTestdrive->setTemplate('testdrive6');
$view = new ViewModel();
$view->addChild($layoutTestdrive);
return $view;

In my module.config.php I did this:

'Zend\View\Resolver\TemplateMapResolver' => array(
'parameters' => array(
'map'  => array(
    'testdrive6' => __DIR__ . '/../../Testdrive/view/layout/testdrive6.phtml'
        ),
    ),
),

Is this correct?

Shaeldon
  • 873
  • 4
  • 18
  • 28
Jorgeley
  • 482
  • 1
  • 6
  • 12
  • Just remembering, I have two modules, the first module must render a layout from another (Testdrive in this case). – Jorgeley Oct 03 '12 at 18:40

1 Answers1

0

Hi i think you need to use forward first

public function commentAction(){     

    $list = $this->forward()->dispatch('comment_controrller', array('action' => 'list'));
    $add = $this->forward()->dispatch('comment_controrller', array('action' => 'add'));

    $view =  new ViewModel();
    $view->addChild($list, 'list');
    $view->addChild($add, 'add');
    return $view;
}

I hope this will help

or if you want just to change template see Different layout file for different controller

Community
  • 1
  • 1
Nikolai Senkevich
  • 2,370
  • 2
  • 19
  • 29