Změna šablony v render metodě

Změna šablony se hodí, pokud chcete vypsat jinou šablonu v případě „404“ nebo „410“.

Změna šablony

<?php

declare(strict_types=1);

namespace App\Presenters;

use Nette;

final class HomepagePresenter extends Nette\Application\UI\Presenter
{

    public function renderDefault(){
        $this->template->render(__DIR__.'/templates/Homepage/jinaSablona.latte');
    }

}

Změna stavového kódu, šablony a ukončení presenteru

<?php

declare(strict_types=1);

namespace App\Presenters;

use Nette;

final class HomepagePresenter extends Nette\Application\UI\Presenter
{

    /**@var Nette\Http\Response $inject*/
    public $httpResponse;

    public function renderDefault(){

        if($podminkaZmeny){
            $this->httpResponse->setCode(410);
            $this->template->render(__DIR__.'/templates/Homepage/410.latte');
            $this->presenter->terminate();
        }

        #jiná akce, pokud podmínka nebyla splněna
    }

}