snab
snab

Reputation: 65

removing footer from specific view in ZF2

How can I remove just the footer from a specific view in ZF2. I have tried

 $View->setTerminal(true);
 return $view;

but it makes the links in the top nav bar inactive. Thanks

Upvotes: 0

Views: 468

Answers (1)

Andrew
Andrew

Reputation: 12809

You could change your base layout for that particular action.

for example, your main layout may be like this example:

layout.phtml

<?php echo $this->doctype(); ?>
<html lang="en">
    <head>
        <?php echo $this->headTitle($this->translate('TITLE'))->setSeparator(' - ')->setAutoEscape(false) ?>
    </head>
    <body>
     ....
          <?php echo $this->partial('footer') ?>
    </body>
 </html>

You can simple make a duplicate layout, but without the footer partial included (or how ever you are including the footer partial/view etc)

you would then tell your action to use a different base layout:

Controller.php

public function testAction()
{
    /**
     * Now we use the base with no footer
     */
    $this->layout('layout/no-footer-layout');
    // identical to below, a shortcut
    //$this->layout()->setTemplate('layout/no-footer-layout');

    return new ViewModel(array(/** etc **/));
}

Upvotes: 2

Related Questions