фильтр из групп ИС

#
фильтр из групп ИС
Доброй ночи и с Новым годом!

помогите пожалуйста)) сделала фильтр по группам..все работает, но пункт "все" повторяется через три пункта, где ошибка

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:hostcms="http://www.hostcms.ru/"
   exclude-result-prefixes="hostcms">
   
   <xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
   
   <!-- СписокЭлементовИнфосистемы -->
   
   <xsl:template match="/">
      <div id="portfolio_wrapper" class="row">
         <xsl:apply-templates select="/informationsystem"/>
      </div>
   </xsl:template>
   
   <xsl:variable name="n" select="number(3)"/>
   
   <xsl:template match="/informationsystem">
      
      <!-- Получаем ID родительской группы и записываем в переменную $group -->
      <xsl:variable name="group" select="group"/>
      
      
      
      
      <!-- Отображение подгрупп данной группы, только если подгруппы есть и не идет фильтра по меткам -->
      <xsl:if test="count(tag) = 0 and count(.//informationsystem_group[parent_id=$group]) &gt; 0">
         
         <div class="text-center filters col-sm-12">
            <ul id="filtrable">
               <xsl:apply-templates select=".//informationsystem_group[parent_id=$group][position() mod $n = 1]" mode="groups"/>
            </ul>
            <div class="clearfix"></div>
         </div>
      </xsl:if>
      
      <!-- Отображение записи информационной системы -->
      <ul class="classes row filtrable clearfix isotope" id="portfolioContainer">
         <xsl:apply-templates select="informationsystem_item"/>
         
      </ul>
      <!-- Строка ссылок на другие страницы информационной системы -->
      <xsl:if test="ОтображатьСсылкиНаСледующиеСтраницы=1">
         <div>
            <!-- Ссылка, для которой дописываются суффиксы page-XX/ -->
            <!-- <xsl:variable name="link">
               <xsl:value-of select="/informationsystem/url"/>
               <xsl:if test="$group != 0">
                  <xsl:value-of select="/informationsystem//informationsystem_group[@id = $group]/url"/>
               </xsl:if>
            </xsl:variable> -->
            
            <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>
               
               <!-- Считаем количество выводимых ссылок перед текущим элементом -->
               <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>
               
               <!-- Считаем количество выводимых ссылок после текущего элемента -->
               <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>
               
               <p>
                  <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>
               </p>
               <div style="clear: both"></div>
            </xsl:if>
         </div>
      </xsl:if>
      
      <xsl:if test="count(informationsystem_group_properties) and group != 0">
         <div style="margin: 10px 0px;">
            <h2>Атрибуты группы инфоэлементов</h2>
            
            <xsl:if test="count(informationsystem_group[@id = //group]/property[parent_id = 0])">
               <table border="0">
                  <xsl:apply-templates select="informationsystem_group[@id = //group]/property[parent_id = 0]"/>
               </table>
            </xsl:if>
            
            <xsl:apply-templates select="informationsystem_group_properties"/>
         </div>
      </xsl:if>
      
      <div style="clear: both"></div>
      
      
      
   </xsl:template>
   
   <!-- Вывод строки со значением свойства -->
   <xsl:template match="property">
      <tr>
         <td style="padding: 5px" bgcolor="#eeeeee">
            <b><xsl:value-of select="name"/></b>
         </td>
         <td style="padding: 5px" bgcolor="#eeeeee">
            <xsl:choose>
               <xsl:when test="type = 1">
                  <a href="{file_path}">Скачать файл</a>
               </xsl:when>
               <xsl:when test="type = 7">
                  <xsl:choose>
                     <xsl:when test="value = 1">
                        <input type="checkbox" checked="" disabled="" />
                     </xsl:when>
                     <xsl:otherwise>
                        <input type="checkbox" disabled="" />
                     </xsl:otherwise>
                  </xsl:choose>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:value-of disable-output-escaping="yes" select="value"/>
               </xsl:otherwise>
            </xsl:choose>
         </td>
      </tr>
   </xsl:template>
   
   <!-- Шаблон выводит рекурсивно ссылки на группы инф. элемента -->
   <xsl:template match="informationsystem_group" mode="breadCrumbs">
      <xsl:variable name="parent_id" select="parent_id"/>
      
      <xsl:apply-templates select="//informationsystem_group[@id=$parent_id]" mode="breadCrumbs"/>
      
      <xsl:if test="parent_id=0">
         <a href="{/informationsystem/url}" hostcms:id="{/informationsystem/@id}" hostcms:field="name" hostcms:entity="informationsystem">
            <xsl:value-of disable-output-escaping="yes" select="/informationsystem/name"/>
         </a>
      </xsl:if>
      
   <span><xsl:text> → </xsl:text></span>
      
      <a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="informationsystem_group">
         <xsl:value-of disable-output-escaping="yes" select="name"/>
      </a>
   </xsl:template>
   
   <!-- Шаблон выводит группы свойств для группы инфосистемы -->
   <xsl:template match="informationsystem_group_properties">
      
   <p><b><xsl:value-of select="information_propertys_groups_dir_name"/></b></p>
      
      <xsl:variable name="dir_id" select="@id"/>
      
      <xsl:if test="count(//informationsystem_group[@id = //group]/property[parent_id = $dir_id])">
         <table border="0">
            <xsl:apply-templates select="//informationsystem_group[@id = //group]/property[parent_id = $dir_id]"/>
         </table>
      </xsl:if>
      
      <xsl:if test="count(informationsystem_group_properties)">
         <blockquote>
            <xsl:apply-templates select="informationsystem_group_properties"/>
         </blockquote>
      </xsl:if>
   </xsl:template>
   
   <!-- Шаблон выводит ссылки подгруппы информационного элемента -->
   <xsl:template match="informationsystem_group" mode="groups">
      
      <xsl:if test="count(/informationsystem/informationsystem_group) > 0">
      <li><a class="selected" data-filter="*" href="#">Все</a></li>
      </xsl:if>
      
      <xsl:for-each select=". | following-sibling::informationsystem_group[position() &lt; $n]">
      <li><a href="#" id="" class="" data-filter=".class_group_{@id}"><xsl:value-of disable-output-escaping="yes" select="name"/></a></li>
      </xsl:for-each>
   </xsl:template>
   
   
   
   <!-- Шаблон вывода информационного элемента -->
   <xsl:template match="informationsystem_item">
      <li class="item col-sm-6 col-md-3 isotope-item class_group_{informationsystem_group_id}" data-id="p-{position()}">
         
      
            <a href="{url}">
               <img src="{dir}{image_large}" alt="" />
            </a>
      
         
         <h3><a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="informationsystem_item">
               <xsl:value-of disable-output-escaping="yes" select="name"/>
         </a></h3>
         <div class="classes-description">
            <!-- Дата время -->
            <p class="with-icon date">
               <xsl:value-of select="substring-before(date, '.')"/>
               <xsl:variable name="month_year" select="substring-after(date, '.')"/>
               <xsl:variable name="month" select="substring-before($month_year, '.')"/>
               <xsl:choose>
                  <xsl:when test="$month = 1"> января </xsl:when>
                  <xsl:when test="$month = 2"> февраля </xsl:when>
                  <xsl:when test="$month = 3"> марта </xsl:when>
                  <xsl:when test="$month = 4"> апреля </xsl:when>
                  <xsl:when test="$month = 5"> мая </xsl:when>
                  <xsl:when test="$month = 6"> июня </xsl:when>
                  <xsl:when test="$month = 7"> июля </xsl:when>
                  <xsl:when test="$month = 8"> августа </xsl:when>
                  <xsl:when test="$month = 9"> сентября </xsl:when>
                  <xsl:when test="$month = 10"> октября </xsl:when>
                  <xsl:when test="$month = 11"> ноября </xsl:when>
                  <xsl:otherwise> декабря </xsl:otherwise>
               </xsl:choose>
               <xsl:value-of select="substring-after($month_year, '.')"/><xsl:text> г.</xsl:text>
            </p>
            
            <xsl:if test="description != ''">
               <p class="with-icon time"><xsl:value-of disable-output-escaping="no"  select="description"/></p>
            </xsl:if>
              
                 <p class="with-icon person"><xsl:apply-templates select="informationsystem_group[@id = //group]/property[parent_id = 0]"/>
      </p>
         </div>
         
      </li>
      
   </xsl:template>
   
   
   
   <!-- Цикл для вывода строк ссылок -->
   <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">
         <span class="ctrl">
            ← Ctrl
         </span>
      </xsl:if>
      
      <xsl:if test="$i = ($page + $post_count_page + 1) and $n != ($page+1)">
         <span class="ctrl">
            Ctrl →
         </span>
      </xsl:if>
      
      <xsl:if test="$items_count &gt; $limit and ($page + $post_count_page + 1) &gt; $i">
         <!-- Заносим в переменную $group идентификатор текущей группы -->
         <xsl:variable name="group" select="/informationsystem/group"/>
         
         <!-- Путь для тэга -->
         <xsl:variable name="tag_path">
            <xsl:choose>
               <!-- Если не нулевой уровень -->
               <xsl:when test="count(/informationsystem/tag) != 0">tag/<xsl:value-of select="/informationsystem/tag/urlencode"/>/</xsl:when>
               <!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
               <xsl:otherwise></xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         
         <!-- Определяем группу для формирования адреса ссылки -->
         <xsl:variable name="group_link">
            <xsl:choose>
               <!-- Если группа не корневая (!=0) -->
               <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>
         
         <!-- Определяем адрес ссылки -->
         <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>
         
         <!-- Выводим ссылку на первую страницу -->
         <xsl:if test="$page - $pre_count_page &gt; 0 and $i = $start_page">
            <a href="{$group_link}{$tag_path}" class="page_link" style="text-decoration: none;">←</a>
         </xsl:if>
         
         <!-- Ставим ссылку на страницу-->
         <xsl:if test="$i != $page">
            <xsl:if test="($page - $pre_count_page) &lt;= $i and $i &lt; $n">
               <!-- Выводим ссылки на видимые страницы -->
               <a href="{$group_link}{$number_link}{$tag_path}" class="page_link">
                  <xsl:value-of select="$i + 1"/>
               </a>
            </xsl:if>
            
            <!-- Выводим ссылку на последнюю страницу -->
            <xsl:if test="$i+1 &gt;= ($page + $post_count_page + 1) and $n &gt; ($page + 1 + $post_count_page)">
               <!-- Выводим ссылку на последнюю страницу -->
               <a href="{$group_link}page-{$n}/{$tag_path}" class="page_link" style="text-decoration: none;">→</a>
            </xsl:if>
         </xsl:if>
         
         <!-- Ссылка на предыдущую страницу для Ctrl + влево -->
         <xsl:if test="$page != 0 and $i = $page">
            <xsl:variable name="prev_number_link">
               <xsl:choose>
                  <!-- Если не нулевой уровень -->
                  <xsl:when test="($page) != 0">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 + вправо -->
         <xsl:if test="($n - 1) > $page and $i = $page">
            <a href="{$group_link}page-{$page+2}/{$tag_path}" id="id_next"></a>
         </xsl:if>
         
         <!-- Не ставим ссылку на страницу-->
         <xsl:if test="$i = $page">
            <span class="current">
               <xsl:value-of select="$i+1"/>
            </span>
         </xsl:if>
         
         <!-- Рекурсивный вызов шаблона. НЕОБХОДИМО ПЕРЕДАВАТЬ ВСЕ НЕОБХОДИМЫЕ ПАРАМЕТРЫ! -->
         <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>
   
   <!-- Склонение после числительных -->
   <xsl:template name="declension">
      
      <xsl:param name="number" select="number"/>
      
      <!-- Именительный падеж -->
      <xsl:variable name="nominative">
         <xsl:text>комментарий</xsl:text>
      </xsl:variable>
      
      <!-- Родительный падеж, единственное число -->
      <xsl:variable name="genitive_singular">
         <xsl:text>комментария</xsl:text>
      </xsl:variable>
      
      
      <xsl:variable name="genitive_plural">
         <xsl:text>комментариев</xsl:text>
      </xsl:variable>
      
      <xsl:variable name="last_digit">
         <xsl:value-of select="$number mod 10"/>
      </xsl:variable>
      
      <xsl:variable name="last_two_digits">
         <xsl:value-of select="$number mod 100"/>
      </xsl:variable>
      
      <xsl:choose>
         <xsl:when test="$last_digit = 1 and $last_two_digits != 11">
            <xsl:value-of select="$nominative"/>
         </xsl:when>
         <xsl:when test="$last_digit = 2 and $last_two_digits != 12
            or $last_digit = 3 and $last_two_digits != 13
            or $last_digit = 4 and $last_two_digits != 14">
            <xsl:value-of select="$genitive_singular"/>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$genitive_plural"/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>
</xsl:stylesheet>


Модератор
#
Re: фильтр из групп ИС
Все верно. Строка:

<li><a class="selected" data-filter="*" href="#">Все</a></li>

Добавлена в темплейт групп, который повторно вызывается каждые 3 группы. Поэтому и "Все" идут каждые 3 пункта. Перенесите ссылку в вызов

<ul id="filtrable">
  <xsl:apply-templates select=".//informationsystem_group[parent_id=$group][position() mod $n = 1]" mode="groups"/>
<li><a class="selected" data-filter="*" href="#">Все</a></li>
</ul>
Вы только что начали читать предложение, чтение которого вы уже заканчиваете.
#
Re: фильтр из групп ИС
alexander.egorov писал(а):


Благодарю!! не думала, что ответите в праздники
Модератор
#
Re: фильтр из групп ИС
ulla,

Пожалуйста.
Вы только что начали читать предложение, чтение которого вы уже заканчиваете.
Авторизация