how to add a site wide menu block to @layout.latte
- simonjcarr
- Member | 28
I have created a folder under templates called sitemenu.
In that folder I have a file called sitemenu.latte with the following code
{block mainmenu}
main Menu code here
{/block}
{block usermenu}
user Menu code here
{/block}
How do I include sitemenu.latte in @layout.latte and conditionally use the different menu blocks?
Last edited by simonjcarr (2016-04-11 19:50)
- Machy8
- Member | 59
You can load another template via latte macro. The conditions can be done by the same way something like:
{if $something === "articles"}
{include 'sidemenu.latte'}
{elseif $something === "homepage"}
...
{else}
...
{/if}
- simonjcarr
- Member | 28
@Machy8 Thanks for the response, but that's not quite what I wanted, but… I did solve my issue.
Inside the include file I want to include in my main layout, I """defined""" some blocks.
menus.latte
{define menu1}
My custom menu 1
{/define}
{define menu2}
My custom menu 2
{define}
then inside @layout.latte I added the following code
{includeblock menus/menus.latte}
Now my file with block definitions is included, I can use the defined blocks normally where I want.
{include menu1}
...
...
{include menu2}
I hope this helps someone else.
Last edited by simonjcarr (2016-04-11 22:44)
- simonjcarr
- Member | 28
As we say in the UK there is more than one way to skin a cat, I think the {define block} method is cleaner though.