i dont know why the next code works fine on windows but on linux NO

4 years ago

alnux
Member | 106
+
0
-

Hi there , i dont know why the next code works fine on windows but on linux show me an FileNotFoundException, you can see it here

protected function beforeRender()
    {
        parent::beforeRender();
        $this->setLayout('../../../../common/templates/@layout');
    }

I thought it was for the @ on the route

Layout not found. Missing template '…/app/front/templates/Index/@../../../../common/templates/@layout.latte'

rewrote so formatLayoutTemplateFiles() method

public function formatLayoutTemplateFiles()
    {
        $name = $this->getName();
        $presenter = substr($name, strrpos(':' . $name, ':'));
        $layout = $this->layout ? $this->layout : 'layout';
        $dir = dirname($this->getReflection()->getFileName());
        $dir = is_dir("$dir/templates") ? $dir : dirname($dir);
        $list = array(
            "$dir/templates/$presenter/$layout.latte", // i add this line
            "$dir/templates/$presenter/@$layout.latte",
            "$dir/templates/$presenter.@$layout.latte",
        );
        do {
            $list[] = "$dir/templates/@$layout.latte";
            $dir = dirname($dir);
        } while ($dir && ($name = substr($name, 0, strrpos($name, ':'))));
        return $list;
    }

but it does not work too, what can be??????

by the way , but when i put the @layout.latte in the corresponding directory and change the code without parent directory

protected function beforeRender()
    {
        parent::beforeRender();
        $this->setLayout('@layout'); //this works
    }

WORKS, but when i trying to put on a parent directory show me the error the pat that i writte on

$this->setLayout('../@layout');

Last edited by alnux (2015-05-17 04:21)

4 years ago

tpr
Member | 55
+
0
-

I would try setting the path with __DIR__ . “/../../../../common/templates/@layout", or substituting "/” in paths with DIRECTORY_SEPARATOR constant.

4 years ago

alnux
Member | 106
+
0
-

it was SOLVED maybe is on nette framework 2.3.2 look here