Using Latte outside of Nette, how to do when main layout is on another folder then common templates?

Notice: This thread is very old.
Member | 2

My Project folder structure is something like:

-- app/
---- layouts/
------ layout.latte
---- modules/
------ pages/
-------- views/
---------- list.latte
---------- add.latte

To make list.latte inherit the layout.latte, I have to do this:

{layout '../../../../app/layouts/layout.latte'}

{block title}First page{/block}

{block content}
	<ul n:if="$items">
	{foreach $items as $item}
	    <li id="item-{$iterator->counter}">{$iterator->counter} - {$item|capitalize}</li>

Is there a better way to do this?

David Matějka
Moderator | 6427

currently, there is no easy way how to resolve layout file automatically. There is opened one PR but I'm not sure it will be merged anytime soon.

Probably best solution for now is to pass layout name as a variable and use it in the template:

{layout $layout}

You can also try to override BlockMacros with your own macroset and fix it somehow.

Member | 2

Ok, it will have to do for now. Thanks for your help David ;)