{block name=pages_navigation_navPages}
    <div class="nav-pages btn-group">
        {if $pages|@count gt 1}
            {assign var=padding value=2}

            {if $actual_page == 1}
                <button class="btn btn-default prev" disabled="disabled" type="button">
                    <i class="fa fa-chevron-left"></i>
                    <span class="sr-only">Prev</span>
                </button>
            {else}
                <a class="btn btn-default prev" role="button" href="{$prev}" rel="prev">
                    <i class="fa fa-chevron-left"></i>
                    <span class="sr-only">Prev</span>
                </a>
            {/if}

            {foreach from=$pages item=page_link key=pager_number}
                {if $pager_number == 1}
                {* <!-- first always --> *}
                    <a class="btn btn-default{if $pager_number == $actual_page} active{/if}" role="button" href="{$page_link}"{if $pager_number == $actual_page-1} rel="prev"{/if}>{$pager_number}</a>
                {/if}
                {if $actual_page - $padding == $pager_number && $actual_page - $padding > 1 && $actual_page - $padding -1  > 1}
                {* <!-- middle block --> *}
                {* <!-- dots before middle block , check padding, no dots between 1 and 2--> *}
                    <button class="btn btn-default dots" disabled="disabled" type="button">...</button>
                {/if}
                {if $pager_number!=1 && $pager_number!=$last_page && $pager_number>=$actual_page-$padding && $pager_number<=$actual_page+$padding}
                    <a class="btn btn-default{if $pager_number == $actual_page} active{/if}" role="button" href="{$page_link}"{if $pager_number == $actual_page-1} rel="prev"{elseif $pager_number == $actual_page+1} rel="next"{/if}>{$pager_number}</a>
                {/if}
                {if $actual_page + $padding == $pager_number && $actual_page + $padding < $last_page && $actual_page + $padding + 1 < $last_page}
                {* <!-- dots after middle block , check padding, no dots between second last and last--> *}
                    <button class="btn btn-default dots" disabled="disabled" type="button">...</button>
                {/if}
                {if $pager_number == $last_page}
                {* <!-- last always --> *}<a class="btn btn-default{if $pager_number == $actual_page} active{/if}" role="button" href="{$page_link}"{if $pager_number == $actual_page+1} rel="next"{/if}>{$pager_number}</a>
    {/if}
            {/foreach}

            {if $actual_page == $last_page}
                <button class="btn btn-default next" disabled="disabled" type="button">
                    <i class="fa fa-chevron-right"></i>
                    <span class="sr-only">Next</span>
                </button>
            {else}
                <a class="btn btn-default next" role="button" href="{$next}" rel="next">
                    <i class="fa fa-chevron-right"></i>
                    <span class="sr-only">Next</span>
                </a>
            {/if}
        {else}
            <button class="btn btn-default one-page" disabled="disabled" type="button">{txt key=TEXT_PAGINATION_TITLE} {$actual_page} {txt key=TEXT_PAGINATION_FROM} {$last_page}</button>
        {/if}
    </div>
{/block}