How can I link a hst:sitemenu to a ftl?

181 Views Asked by At

I am trying to link a menu to his correspondent ftl and I don´t understand which are the proper steps I have to take. I didn´t found any usefull documentation about it. All the help is welcomed.

1

There are 1 best solutions below

0
Jasper Floor On

Basically, you need to retrieve the menu in a component and put that on the request. In the ftl you can then reference the menu. You can use the essentials menu component or the dynamic menu component. Or you have a custom component. I'd suggest starting an archetype project and installing the simple content from essentials. This should add a menu that you can look at to see how it works.

An example from one of our online tutorials looks like this:

<#include "../include/imports.ftl">
<#if menu??>
  <div class="hst-container">
    <div class="hst-container-item">
      <#if menu.siteMenuItems??>
        <#list menu.siteMenuItems as item>
          <#if item.selected || item.expanded>
            <div class="list-group left-nav">
              <a href="<@hst.link link=item.hstLink/>" class="list-group-item level1">${item.name?html}</a>
                <#list item.childMenuItems as item>
                  <a href="<@hst.link link=item.hstLink/>" class="list-group-item level2"><i class="fa fa-angle-right"> </i>${item.name?html}</a>
                </#list>
            </div>
          </#if>
        </#list>
      </#if>
    </div>
  </div>
</#if>