{include file="$template/pageheader.tpl" title=$LANG.knowledgebasetitle icon=notebook}
<form role="form" method="post" action="{routePath('knowledgebase-search')}">
  <div class="input-group kb-search p-1">
    <input type="text" id="inputKnowledgebaseSearch" name="search" class="form-control" placeholder="What can we help you with?" />
    <span class="input-group-btn">
      <button type="submit" class="btn btn-primary"><i class="fas fa-search"></i></button>
    </span>
  </div>
</form>
{include file="$template/subheader.tpl" title=$LANG.knowledgebasecategories}
{if $kbcats}
<div class="row px-1">
  {foreach from=$kbcats name=kbcats item=kbcat}
  <div class="col-md-4">
    <h4><a href="{routePath('knowledgebase-category-view', {$kbcat.id}, {$kbcat.urlfriendlyname})}">
      <span class="glyphicon glyphicon-folder-close"></span>
      {$kbcat.name} <span class="badge">{$kbcat.numarticles}</span>
    </a>
                {if $kbcat.editLink}
                    <a href="{$kbcat.editLink}" class="admin-inline-edit">
                        <i class="fas fa-pencil fa-fw"></i>
                        {$LANG.edit}
                    </a>
                {/if}
                </h4>
    <p>{$kbcat.description}</p>
  </div>
  {if $smarty.foreach.kbcats.iteration mod 3 == 0}
</div><div class="row px-1">
  {/if}
  {/foreach}
</div>
{else}
{include file="$template/includes/alert.tpl" type="info" msg=$LANG.knowledgebasenoarticles textcenter=true}
{/if}

{if $kbmostviews}

{include file="$template/subheader.tpl" title=$LANG.knowledgebasepopular}
{foreach from=$kbmostviews name=kbmostviews item=kbarticle}
{if $smarty.foreach.kbmostviews.iteration is odd}
<div class="row row-eq-height px-1">
  {/if}
    <div class="col-md-6">
      <div class="well well-sm">
        <h4><a href="{routePath('knowledgebase-article-view', {$kbarticle.id}, {$kbarticle.urlfriendlytitle})}">
          <span class="glyphicon glyphicon-file"></span>&nbsp;{$kbarticle.title}
        </a>
                    {if $kbarticle.editLink}
                <a href="{$kbarticle.editLink}" class="admin-inline-edit">
                    <i class="fas fa-pencil fa-fw"></i>
                    {$LANG.edit}
                </a>
            {/if}
        </h4>
        <p>{$kbarticle.article|truncate:240:"..."}</p>
      </div>
    </div>
{if $smarty.foreach.kbmostviews.iteration mod 2 == 0 ||  $smarty.foreach.kbmostviews.last}
</div>
{/if}
{/foreach}
{/if}
