Своя Pagination как переделать?

#
Своя Pagination как переделать?
Есть задача вывести offset, limit в queryBuilder вывести записи. Смотрю Pagination в XSL ИС пробую  но что то не понятно для меня работает алгоритм
<!-- Pagination -->
         <div>
            <xsl:if test="total &gt; 0 and limit &gt; 0">
               
               <xsl:variable name="count_pages" select="ceiling(total div limit)"/>
               
               <xsl:variable name="visible_pages" select="5"/>
               
               <xsl:variable name="real_visible_pages"><xsl:choose>
                     <xsl:when test="$count_pages &lt; $visible_pages"><xsl:value-of select="$count_pages"/></xsl:when>
                     <xsl:otherwise><xsl:value-of select="$visible_pages"/></xsl:otherwise>
               </xsl:choose></xsl:variable>
               
               <!-- Links before current -->
               <xsl:variable name="pre_count_page"><xsl:choose>
                     <xsl:when test="page - (floor($real_visible_pages div 2)) &lt; 0">
                        <xsl:value-of select="page"/>
                     </xsl:when>
                     <xsl:when test="($count_pages - page - 1) &lt; floor($real_visible_pages div 2)">
                        <xsl:value-of select="$real_visible_pages - ($count_pages - page - 1) - 1"/>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:choose>
                           <xsl:when test="round($real_visible_pages div 2) = $real_visible_pages div 2">
                              <xsl:value-of select="floor($real_visible_pages div 2) - 1"/>
                           </xsl:when>
                           <xsl:otherwise>
                              <xsl:value-of select="floor($real_visible_pages div 2)"/>
                           </xsl:otherwise>
                        </xsl:choose>
                     </xsl:otherwise>
               </xsl:choose></xsl:variable>
               
               <!-- Links after current -->
               <xsl:variable name="post_count_page"><xsl:choose>
                     <xsl:when test="0 &gt; page - (floor($real_visible_pages div 2) - 1)">
                        <xsl:value-of select="$real_visible_pages - page - 1"/>
                     </xsl:when>
                     <xsl:when test="($count_pages - page - 1) &lt; floor($real_visible_pages div 2)">
                        <xsl:value-of select="$real_visible_pages - $pre_count_page - 1"/>
                     </xsl:when>
                     <xsl:otherwise>
                        <xsl:value-of select="$real_visible_pages - $pre_count_page - 1"/>
                     </xsl:otherwise>
               </xsl:choose></xsl:variable>
               
               <xsl:variable name="i"><xsl:choose>
                     <xsl:when test="page + 1 = $count_pages"><xsl:value-of select="page - $real_visible_pages + 1"/></xsl:when>
                     <xsl:when test="page - $pre_count_page &gt; 0"><xsl:value-of select="page - $pre_count_page"/></xsl:when>
                     <xsl:otherwise>0</xsl:otherwise>
               </xsl:choose></xsl:variable>
               
               <nav>
                  <ul class="pagination">
                     <xsl:call-template name="for">
                        <xsl:with-param name="limit" select="limit"/>
                        <xsl:with-param name="page" select="page"/>
                        <xsl:with-param name="items_count" select="total"/>
                        <xsl:with-param name="i" select="$i"/>
                        <xsl:with-param name="post_count_page" select="$post_count_page"/>
                        <xsl:with-param name="pre_count_page" select="$pre_count_page"/>
                        <xsl:with-param name="visible_pages" select="$real_visible_pages"/>
                     </xsl:call-template>
                  </ul>
               </nav>
            </xsl:if>
         </div>


<!-- Pagination -->
   <xsl:template name="for">
      
      <xsl:param name="limit"/>
      <xsl:param name="page"/>
      <xsl:param name="pre_count_page"/>
      <xsl:param name="post_count_page"/>
      <xsl:param name="i" select="0"/>
      <xsl:param name="items_count"/>
      <xsl:param name="visible_pages"/>
      
      <xsl:variable name="n" select="ceiling($items_count div $limit)"/>
      
      <xsl:variable name="start_page"><xsl:choose>
            <xsl:when test="$page + 1 = $n"><xsl:value-of select="$page - $visible_pages + 1"/></xsl:when>
            <xsl:when test="$page - $pre_count_page &gt; 0"><xsl:value-of select="$page - $pre_count_page"/></xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose></xsl:variable>
      
      <xsl:if test="$i = $start_page and $page != 0">
         <li>
         <span aria-hidden="true"><i class="fa fa-angle-double-left"></i></span>
         </li>
      </xsl:if>
      
      <xsl:if test="$i = ($page + $post_count_page + 1) and $n != ($page+1)">
         <li>
         <span aria-hidden="true"><i class="fa fa-angle-double-right"></i></span>
         </li>
      </xsl:if>
      
      <xsl:if test="$items_count &gt; $limit and ($page + $post_count_page + 1) &gt; $i">
         <!-- Store in the variable $group ID of the current group -->
         <xsl:variable name="group" select="/informationsystem/group"/>
         
         <!-- Tag Path -->
         <xsl:variable name="tag_path">
            <xsl:choose>
               
               <xsl:when test="count(/informationsystem/tag)">tag/<xsl:value-of select="/informationsystem/tag/urlencode"/>/</xsl:when>
               
               <xsl:otherwise></xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         
         <!-- Choose Group Path -->
         <xsl:variable name="group_link">
            <xsl:choose>
               <!-- If the group is not root -->
               <xsl:when test="$group != 0">
                  <xsl:value-of select="/informationsystem//informationsystem_group[@id=$group]/url"/>
               </xsl:when>
               
               <xsl:otherwise><xsl:value-of select="/informationsystem/url"/></xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         
         <!-- Set $link variable -->
         <xsl:variable name="number_link">
            <xsl:choose>
               
               <xsl:when test="$i != 0">page-<xsl:value-of select="$i + 1"/>/</xsl:when>
               
               <xsl:otherwise></xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         
         <!-- First pagination item -->
         <xsl:if test="$page - $pre_count_page &gt; 0 and $i = $start_page">
            <li>
               <a href="{$group_link}{$tag_path}" class="page_link" style="text-decoration: none;">←</a>
            </li>
         </xsl:if>
         
         <!-- Pagination item -->
         <xsl:if test="$i != $page">
            <xsl:if test="($page - $pre_count_page) &lt;= $i and $i &lt; $n">
               <li>
                  <!-- Pagination item -->
                  <a href="{$group_link}{$number_link}{$tag_path}" class="page_link">
                     <xsl:value-of select="$i + 1"/>
                  </a>
               </li>
            </xsl:if>
            
            <!-- Last pagination item -->
            <xsl:if test="$i+1 &gt;= ($page + $post_count_page + 1) and $n &gt; ($page + 1 + $post_count_page)">
               <li>
                  <!-- Last pagination item -->
                  <a href="{$group_link}page-{$n}/{$tag_path}" class="page_link" style="text-decoration: none;">→</a>
               </li>
            </xsl:if>
         </xsl:if>
         
         <!-- Ctrl+left link -->
         <xsl:if test="$page != 0 and $i = $page">
            <xsl:variable name="prev_number_link">
               <xsl:choose>
                  
                  <xsl:when test="$page &gt; 1">page-<xsl:value-of select="$i"/>/</xsl:when>
                  
                  <xsl:otherwise></xsl:otherwise>
               </xsl:choose>
            </xsl:variable>
            
            <a href="{$group_link}{$prev_number_link}{$tag_path}" id="id_prev"></a>
         </xsl:if>
         
         <!-- Ctrl+right link -->
         <xsl:if test="($n - 1) > $page and $i = $page">
            <a href="{$group_link}page-{$page+2}/{$tag_path}" id="id_next"></a>
         </xsl:if>
         
         <!-- Current pagination item -->
         <xsl:if test="$i = $page">
            <span class="current">
               <xsl:value-of select="$i+1"/>
            </span>
         </xsl:if>
         
         <!-- Recursive Template -->
         <xsl:call-template name="for">
            <xsl:with-param name="i" select="$i + 1"/>
            <xsl:with-param name="limit" select="$limit"/>
            <xsl:with-param name="page" select="$page"/>
            <xsl:with-param name="items_count" select="$items_count"/>
            <xsl:with-param name="pre_count_page" select="$pre_count_page"/>
            <xsl:with-param name="post_count_page" select="$post_count_page"/>
            <xsl:with-param name="visible_pages" select="$visible_pages"/>
         </xsl:call-template>
      </xsl:if>
   </xsl:template>


/shop/mod_count это общее количество записей на данном этапе общее количество записей = 8 шт.
$lim это лимит вывода, равно = 2 шт. на страницу
Меня так:

<!-- Pagination -->
                <xsl:if test="/shop/mod_count > 2">
                    <div>

                        <xsl:variable name="lim" select="2"/>

                        <xsl:variable name="count_pages" select="ceiling(/shop/mod_count div $lim)"/>

                        <xsl:variable name="visible_pages" select="5"/>

                        <xsl:variable name="real_visible_pages"><xsl:choose>
                            <xsl:when test="$count_pages &lt; $visible_pages"><xsl:value-of select="$count_pages"/></xsl:when>
                            <xsl:otherwise><xsl:value-of select="$visible_pages"/></xsl:otherwise>
                        </xsl:choose></xsl:variable>

                        <!-- Links before current -->
                        <xsl:variable name="pre_count_page"><xsl:choose>

                            <xsl:when test="($count_pages - 1) &lt; floor($real_visible_pages div 2)">
                                <xsl:value-of select="$real_visible_pages - ($count_pages - 1) - 1"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:choose>
                                    <xsl:when test="round($real_visible_pages div 2) = $real_visible_pages div 2">
                                        <xsl:value-of select="floor($real_visible_pages div 2) - 1"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:value-of select="floor($real_visible_pages div 2)"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:otherwise>
                        </xsl:choose></xsl:variable>

                        <!-- Links after current -->
                        <xsl:variable name="post_count_page"><xsl:choose>
                            <xsl:when test="0 &gt; (floor($real_visible_pages div 2) - 1)">
                                <xsl:value-of select="$real_visible_pages - 1"/>
                            </xsl:when>
                            <xsl:when test="($count_pages - 1) &lt; floor($real_visible_pages div 2)">
                                <xsl:value-of select="$real_visible_pages - $pre_count_page - 1"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$real_visible_pages - $pre_count_page - 1"/>
                            </xsl:otherwise>
                        </xsl:choose></xsl:variable>

                        <xsl:variable name="i"><xsl:choose>
                            <xsl:when test="page + 1 = $count_pages"><xsl:value-of select="page - $real_visible_pages + 1"/></xsl:when>
                            <xsl:when test="page - $pre_count_page &gt; 0"><xsl:value-of select="page - $pre_count_page"/></xsl:when>
                            <xsl:otherwise>0</xsl:otherwise>
                        </xsl:choose></xsl:variable>

                        <nav>
                            <ul class="pagination">
                                <xsl:call-template name="for">
                                    <xsl:with-param name="limit" select="$lim"/>
                                    <xsl:with-param name="page" select="0"/>
                                    <xsl:with-param name="items_count" select="/shop/mod_count"/>
                                    <xsl:with-param name="i" select="$i"/>
                                    <xsl:with-param name="post_count_page" select="$post_count_page"/>
                                    <xsl:with-param name="pre_count_page" select="$pre_count_page"/>
                                    <xsl:with-param name="visible_pages" select="$real_visible_pages"/>
                                </xsl:call-template>
                            </ul>
                        </nav>

                    </div>
                </xsl:if>
                <!-- END Pagination -->

<!-- Pagination -->
    <xsl:template name="for">

        <xsl:param name="limit"/>
        <xsl:param name="page"/>
        <xsl:param name="pre_count_page"/>
        <xsl:param name="post_count_page"/>
        <xsl:param name="i" select="0"/>
        <xsl:param name="items_count"/>
        <xsl:param name="visible_pages"/>

        <xsl:variable name="n" select="ceiling($items_count div $limit)"/>

        <xsl:variable name="start_page"><xsl:choose>
            <xsl:when test="$page + 1 = $n"><xsl:value-of select="$page - $visible_pages + 1"/></xsl:when>
            <xsl:when test="$page - $pre_count_page &gt; 0"><xsl:value-of select="$page - $pre_count_page"/></xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose></xsl:variable>


        <xsl:if test="$i = $start_page and $page != 0">
             <li>
                 <!--<span aria-hidden="true"><i class="fa fa-angle-double-left"></i></span>-->
             </li>
         </xsl:if>

         <xsl:if test="$i = ($page + $post_count_page + 1) and $n != ($page+1)">
             <li>
                 <!--<span aria-hidden="true"><i class="fa fa-angle-double-right"></i></span>-->
             </li>
        </xsl:if>

        <xsl:if test="$items_count &gt; $limit and ($page + $post_count_page + 1) &gt; $i">


            <!-- Set $link variable -->
            <xsl:variable name="number_link">
                <xsl:choose>

                    <xsl:when test="$i != 0">page-<xsl:value-of select="$i + 1"/>/</xsl:when>

                    <xsl:otherwise></xsl:otherwise>
                </xsl:choose>
            </xsl:variable>

            <!-- First pagination item
            <xsl:if test="$page - $pre_count_page &gt; 0 and $i = $start_page">
                <li>
                    <a href="{$group_link}{$tag_path}" class="page_link" style="text-decoration: none;">←</a>
                </li>
            </xsl:if> -->

            <!-- Pagination item -->
            <xsl:if test="$i != $page">
                <xsl:if test="($page - $pre_count_page) &lt;= $i and $i &lt; $n">
                    <li class="page_link">
                        <!-- Pagination item -->
                        <a href="{$number_link}">
                            <xsl:value-of select="$i + 1"/>n=<xsl:value-of select="$i"/>
                        </a>
                    </li>
                </xsl:if>

                <!-- Last pagination item -->
                <xsl:if test="$i+1 &gt;= ($page + $post_count_page + 1) and $n &gt; ($page + 1 + $post_count_page)">
                    <li class="page_link">
                        <a href="page-{$n}/"><xsl:value-of select="$n"/></a>
                    </li>
                </xsl:if>
            </xsl:if>

            <!-- Ctrl+left link-->
            <xsl:if test="$page != 0 and $i = $page">
                <xsl:variable name="prev_number_link">
                    <xsl:choose>

                        <xsl:when test="$page &gt; 1">page-<xsl:value-of select="$i"/>/</xsl:when>

                        <xsl:otherwise></xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>

                <!--<a href="{$prev_number_link}" id="id_prev"></a>-->
            </xsl:if>

            <!-- Ctrl+right link-->
            <xsl:if test="($n - 1) > $page and $i = $page">
                <!--<a href="page-{$page+2}/" id="id_next"></a>-->
            </xsl:if>

            <!-- Current pagination item -->
            <xsl:if test="$i = $page">
                <li class="current"><xsl:value-of select="$i+1"/></li>
            </xsl:if>

            <!-- Recursive Template -->
            <xsl:call-template name="for">
                <xsl:with-param name="i" select="$i + 1"/>
                <xsl:with-param name="limit" select="$limit"/>
                <xsl:with-param name="page" select="$page"/>
                <xsl:with-param name="items_count" select="$items_count + 1"/>
                <xsl:with-param name="pre_count_page" select="$pre_count_page"/>
                <xsl:with-param name="post_count_page" select="$post_count_page"/>
                <xsl:with-param name="visible_pages" select="$visible_pages"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>

Вот что получаю
https://image.prntscr.com/image/Q-sr-cG3Qb6-QVsDnEeoxA.png
Может кто сталкивался делать свои пагинации в XSL может кто поделится?
E-mail: info@syrbek.ru / телега: @syrbek /skype: activexm / syrbek.ru / Поддержка сайтов / г. Москва [HTML, CSS (Bootstrap), JS(JQuery, ExtJS), PHP, MySQL, MSSql, Posgres, Git, SVN, Redmine]
#
Re: Своя Pagination как переделать?
Как всегда истина была где то рядом. Нашел в XSL шаблонах.
/shop/mod_count - всего записей
$limit - вывод на страницу
Вызов в нужном месте:

<!-- Pagination -->
<xsl:if test="/shop/mod_count > 2">
    <xsl:variable name="limit" select="2"/>
    <ul class="pagination mod-pagination">
        <xsl:call-template name="mod_for">
            <xsl:with-param name="items_on_page" select="$limit"/>
            <xsl:with-param name="current_page" select="0"/>
            <xsl:with-param name="count_items" select="/shop/mod_count"/>
        </xsl:call-template>
    </ul>
</xsl:if>
<!-- END Pagination -->

Сам шаблон:

<!-- Pagination -->
<xsl:template name="mod_for">
    <xsl:param name="i" select="0"/>
    <xsl:param name="items_on_page"/>
    <xsl:param name="current_page"/>
    <xsl:param name="count_items"/>
    <xsl:variable name="n" select="$count_items div $items_on_page"/>
    <xsl:if test="$count_items &gt; $items_on_page and $n &gt; $i">
        <!-- Pagination item -->
        <xsl:if test="$i != $current_page">
            <!-- Set $link variable -->
            <xsl:variable name="number_link">
                <xsl:choose>
                    <xsl:when test="$i != 0"><xsl:value-of select="$i + 1"/></xsl:when>
                    <xsl:otherwise></xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <li class="page_link" data-link="{$number_link}">
                <xsl:value-of select="$i + 1"/>
            </li>
        </xsl:if>
        <!-- Current pagination item -->
        <xsl:if test="$i = $current_page">
            <li class="current" data-link="{$i+1}">
                <xsl:value-of select="$i+1"/>
            </li>
        </xsl:if>
        <!-- Recursive Template -->
        <xsl:call-template name="mod_for">
            <xsl:with-param name="i" select="$i + 1"/>
            <xsl:with-param name="items_on_page" select="$items_on_page"/>
            <xsl:with-param name="current_page" select="$current_page"/>
            <xsl:with-param name="count_items" select="$count_items"/>
        </xsl:call-template>
    </xsl:if>
</xsl:template>
E-mail: info@syrbek.ru / телега: @syrbek /skype: activexm / syrbek.ru / Поддержка сайтов / г. Москва [HTML, CSS (Bootstrap), JS(JQuery, ExtJS), PHP, MySQL, MSSql, Posgres, Git, SVN, Redmine]
Авторизация