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

Notice: This thread is very old.
rafamds
Member | 2
+
0
-

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:

<?php
{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>
	{/foreach}
	</ul>
{/block}
?>

Is there a better way to do this?

David Matějka
Moderator | 6445
+
+1
-

Hi,
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.

rafamds
Member | 2
+
0
-

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