{function sectionsTree}
   <ul class="list-unstyled sidebar-sections-nav sidebar-sections-nav-{$level}">
      {foreach $sectionList as $item}
         <li class="sidebar-navitem section_{$item.id}" data-sidesections-navitem>
            <a href="{url s=category IDcat=$item.id}" class="navlink">
               <span>{$item.title_short}</span>
            </a>

            {if $item.submenu and $item.level < $level_max}
               {sectionsTree sectionList=$item.submenu level=$item.level}
            {/if}
         </li>
      {/foreach}
   </ul>
{/function}

{if not $fromCache}
   {if $categories}
      <div class="sidebar-sections" data-sidesections>
         {block "sidebar-sections-header"}{/block}
         {sectionsTree sectionList=$categories level=0}
      </div>
   {/if}
{else}
   {if $selection}
      <script>
         wpj.onReady.push(function() {
            {foreach $selection as $item}
            $("[data-sidesections] .section_{$item}").addClass('active');
            {/foreach}
         });
      </script>
   {/if}
{/if}
