<h1>{t}Vyhledávání{/t} {t}„{/t}{$body.search}{t}“{/t}</h1>

{$products = $body.results.products}

{if $products.list|count}
   {$activeTab = "products"}
{elseif $body.results.sections.list}
   {$activeTab = "sections"}
{elseif $body.results.producers.list}
   {$activeTab = "producers"}
{elseif $body.results.articles.list}
   {$activeTab = "articles"}
{elseif $body.results.pages.list}
   {$activeTab = "pages"}
{else}
   {$activeTab = "products"}
{/if}

<div class="search-types">
   <div class="tabs search-tabs" data-tabs="search-results">
      <a href="#tabs-products" data-tab-target="#tabs-products" data-tabs="nav" class="nav-link{if $activeTab == "products"} active{/if}">
          {t pocet=$products.pager.total}Produkty ({pocet}){/t}</a>
      <div class="tab-pane{if $activeTab == "products"} active{/if}" id="tabs-products" data-tabs="content">
         <div class="category-body">
            {if $products.list|count}
               <div class="category-products">
                  {include "block.products.tpl" products=$products.list}
                  {include "components/pager.tpl" pager=$products.pager show_arrows=true}
               </div>
            {else}
               {insert_page type="EMPTY_SEARCH" exists='exists'}
               {if !$exists}
                  <div class="alert alert-info">
                     {t}Nenalezeno žádné zboží odpovídající těmto vlastnostem.{/t}
                  </div>
               {/if}
            {/if}
         </div>
      </div>

      <a href="#tabs-sections" data-tab-target="#tabs-sections" data-tabs="nav" class="nav-link{if $activeTab == "sections"} active{/if}">
         {t}Kategorie{/t} ({$body.results.sections.list|count})</a>
      <div class="tab-pane{if $activeTab == "sections"} active{/if}" id="tabs-sections" data-tabs="content">
         {if $body.results.sections.list}
            <div class="row subsections">
               {foreach $body.results.sections.list as $section}
                  {block "search-result-section"}
                     <div class="subsection-item search-results-item col-xxs-12 col-sm-6 col-md-4 col-xl-3">
                        <a href="{url s=category IDcat=$section.id}" class="subsection-item-inner">
                           <span class="subsection-item-title">{$section.name}</span>
                        </a>
                     </div>
                  {/block}
               {/foreach}
            </div>
         {else}
            <div class="alert alert-info">
               {t}Nenalezena žádná kategorie odpovídající těmto vlastnostem.{/t}
            </div>
         {/if}
      </div>

      {ifmodule PRODUCERS}
         <a href="#tabs-producers" data-tab-target="#tabs-producers" data-tabs="nav"
            class="nav-link{if $activeTab == "producers"} active{/if}">
            {t}Značky{/t} ({$body.results.producers.list|count})</a>
         <div class="tab-pane{if $activeTab == "producers"} active{/if}" id="tabs-producers" data-tabs="content">
            {if $body.results.producers.list}
               <div class="row subsections">
                  {foreach $body.results.producers.list as $producer}
                     <div class="subsection-item search-results-item col-xxs-12 col-sm-6 col-md-4 col-xl-3">
                        <a href="{url s=category IDpd=$producer.id producerTitle=$producer.name}" class="subsection-item-inner">
                           <span class="subsection-item-title">{$producer.name}</span>
                        </a>
                     </div>
                  {/foreach}
               </div>
            {else}
               <div class="alert alert-info">
                  {t}Nenalezena žádná značka odpovídající těmto vlastnostem.{/t}
               </div>
            {/if}
         </div>
      {/ifmodule}

      {ifmodule ARTICLES}
         <a href="#tabs-articles" data-tab-target="#tabs-articles" data-tabs="nav"
            class="nav-link{if $activeTab == "articles"} active{/if}">
            {t}Články{/t} ({$body.results.articles.list|count})</a>
         <div class="tab-pane{if $activeTab == "articles"} active{/if}" id="tabs-articles" data-tabs="content">
            {if $body.results.articles.list}
               <div class="search-blog">
                  {$id_array = []}
                  {foreach $body.results.articles.list as $article}
                     {$id_array[$article.id] = $article.id}
                  {/foreach}
                  {insert_articles id=$id_array order_by=$id_array assign="articles"}
                  {if $articles.articles}
                     {block "search-results-articles"}
                        {include "block.articles.tpl" articles=$articles.articles}
                     {/block}
                  {/if}
               </div>
            {else}
               <div class="alert alert-info">
                  {t}Nenalezen žádný článek odpovídající těmto vlastnostem.{/t}
               </div>
            {/if}
         </div>
      {/ifmodule}

      <a href="#tabs-menuitems" data-tab-target="#tabs-menuitems" data-tabs="nav" class="nav-link{if $activeTab == "pages"} active{/if}">
         {t}Ostatní{/t} ({$body.results.pages.list|count})</a>
      <div class="tab-pane{if $activeTab == "pages"} active{/if}" id="tabs-menuitems" data-tabs="content">
         {if $body.results.pages.list}
            <div class="row subsections">
               {foreach $body.results.pages.list as $page}
                  <div class="subsection-item search-results-item col-xxs-12 col-sm-6 col-md-4 col-xl-3">
                     <a href="{$page.url}" class="subsection-item-inner">
                        <span class="subsection-item-title">{$page.name}</span>
                     </a>
                  </div>
               {/foreach}
            </div>
         {else}
            <div class="alert alert-info">
               {t}Nenalezena žádná stránka odpovídající těmto vlastnostem.{/t}
            </div>
         {/if}
      </div>
   </div>
</div>
