Roby Sottini
Roby Sottini

Reputation: 2265

Yii2: don't show footer for some views

I want to not show the footer of a typical Yii view. View

The function that render the view is very short:

public function actionPrintReport() {
    return $this->render('_myReport', []);
}

How can I hide it?

Upvotes: 0

Views: 839

Answers (3)

user13580916
user13580916

Reputation: 11

You could use renderPartial as below:

public function actionPrintReport() {
    return $this->renderPartial('_myReport', []);
}

Upvotes: 1

ScaisEdge
ScaisEdge

Reputation: 133360

for simply remove the tool bar you should check in your view/layout and remove the footer part form the layout you are using ..

eg for the default layout name main.php
you can simply comment the related part eg:

<footer class="footer">
    <div class="container">
    <p class="pull-left">&copy; my Copy  <?= date('Y') ?></p>
    <!--p class="pull-right"><?= Yii::powered() ?></p-->
    </div>
</footer>

instead if you want remove the debut toolbar showd click on botton right side with the yii logo

you must look in you config file main-local.php or main.php and commment or remove the part that invoke the debug tool eg: commenting the boostrap invocation

if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    // $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = 'yii\debug\Module';

commenti the $config['bootstrap'] the related code is not loaded and use

Upvotes: 0

Ash-b
Ash-b

Reputation: 713

you can create your custom layout and use it wherever you want to hide the footer

public function actionPrintReport() {

   $this->layout = 'yourNewLayout';

   return $this->render('_myReport', []);
}

go to app\view\layouts and create a new layout. ( copy the existing layout and just remove the footer from it)

Upvotes: 2

Related Questions