{function header_submenu}
    {foreach $categories as $item}
       <div class="submenu-section-item">
          <p class="title-default">
             <a href="{url s=category IDcat=$item.id}">{$item.title_short}</a>
          </p>
           {if $item.submenu and $item.level < $level_max}
              <ul>
                  {foreach $item.submenu as $sub_item}
                     <li>
                        <a href="{url s=category IDcat=$sub_item.id TM=$sub_item.uid TITLE=$sub_item.title parents=$sub_item.parents}">{$sub_item.title_short}</a>
                     </li>
                  {/foreach}
              </ul>
           {/if}
       </div>
    {/foreach}
{/function}

{if not $fromCache}
   {$brands_section_id = 377}
   <ul class="level-0" data-sections="header">
       {foreach $categories as $item}
           {if $item.virtual == 'N' or !($item.virtual == "Y" and $hide_virtual)}
              <li class="nav-item {if ($item.submenu and $item.level < $level_max) or $item.id == $brands_section_id}has-submenu{/if}"
                  data-navitem="{$item.id}">
                 <a href="{url s=category IDcat=$item.id}"
                    class="nav-link">{$item.title_short}</a>

                  {if $item.submenu and $item.level < $level_max}
                      {insert_products type="product" id=$item.data.products image=2 template=null show_producer=1 count=1 assign="submenu_products"}
                     <div class="submenu{if $submenu_products.products|count} with-product{/if}">
                        <div class="container">
                           <div class="submenu-inner">

                               {get_section id=$item.id assign=category}
                               {if $category.blocks['menu_special'] and $category.blocks['menu_special'].content|strip_tags|count_characters}
                                  <div class="submenu-campaigns">
                                     {$category.blocks['menu_special']|inline_edit nofilter}
                                  </div>
                               {/if}

                              <div class="submenu-sections">
                                  {header_submenu categories=$item.submenu virtual=false}
                              </div>

                               {if $submenu_products.products|count}
                                   {include 'components/block.product.submenu.tpl' catalog_class='c'}
                               {/if}
                           </div>

                           <div class="submenu-producers">
                              <strong>{t}Oblíbené značky{/t}</strong>
                               {insert_producers top=true count=8 category=$item.id hide_btn=true key="submenu_category_{$item.id}"}
                              <a href="{url s=producers}" class="btn-link">{t}Všechny značky{/t}</a>
                           </div>
                        </div>
                     </div>
                  {elseif $item.id == $brands_section_id}
                      <div class="submenu">
                         <div class="container">
                             <div class="submenu-producers-all">
                                 {insert_producers count=10 top=true title=false header_submenu=true key="submenu_category"}
                             </div>
                         </div>
                      </div>
                  {/if}
              </li>
           {/if}
       {/foreach}
   </ul>
{else}
   <script>
      wpj.onReady.push(function () {
          {if $selection}
          {foreach $selection as $item}
         $('[data-sections="header"] [data-navitem="' + {$item} + '"]').addClass('active');
          {/foreach}
          {/if}
      });
   </script>
{/if}
