Отображение флажков в фильтре и фильтрация по модификациям

#
Отображение флажков в фильтре и фильтрация по модификациям
Стала проблема такого характера:
В свойствах товара был заведен раздел "Коллекция", в котором были созданы свойства(их необходимо использовать при фильтрации товара) со Способом отображения - Флажок и Тип - Флажок.
Эти свойства в виде флажков выводятся в фильтре в каталоге товаров, но не показываются в фильтре, когда я захожу непосредственно в товар. Как сделать так, чтобы когда мы находимся в товаре, в фильтре тоже отображались эти самые свойства?

И второй вопрос - Как можно фильтровать только по модификациям товара, не затрагивая родительский товар, и тоже с одной особенностью - не искать везде, если в фильтре не отмечены флажки.

Заранее, Спасибо!
Модератор
#
Re: Отображение флажков в фильтре и фильтрация по модификациям
x404 писал(а):
Эти свойства в виде флажков выводятся в фильтре в каталоге товаров, но не показываются в фильтре, когда я захожу непосредственно в товар.

О каком фильтре внутри товара идет речь?
#
Re: Отображение флажков в фильтре и фильтрация по модификациям
упс, совсем закрутился.. Я о том, в котором "Цена от .. до..", вообщем я его туда попытался сам сдублировать из xsl шаблона каталога товаров
#
Re: Отображение флажков в фильтре и фильтрация по модификациям
помогите найти решение плиз
Модератор
#
Re: Отображение флажков в фильтре и фильтрация по модификациям
x404,
проверьте параметры, которые передаются при показе фильтра. Может быть у Вас ID группы где-то теряется и поэтому список свойств не получается. По такому описанию могу только это посоветовать.
#
Re: Отображение флажков в фильтре и фильтрация по модификациям
Код, который у меня отвечает за вывод страницы товара..
В теле <xsl:template match="properties_for_group/property"> пытался
вместо @id прописывать @group... безрезультатно..



<?xml version="1.0" encoding="windows-1251"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="Windows-1251" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
   
   <!-- МагазинТовар -->
   
   <xsl:decimal-format name="my" decimal-separator="," grouping-separator=" "/>
   
   <xsl:template match="/shop">
      <xsl:apply-templates select="item"/>
   </xsl:template>
   
   

      <xsl:template match="item">
         <div class="product">
            <SCRIPT>
               <xsl:comment>
                  <xsl:text disable-output-escaping="yes">
                     <![CDATA[
                     
                     // массив для хранения текущих рейтингов звезд
                     var curr_rate = new Array();
                     
                     // функция работы со звездами рейтинга
                     function set_rate(id, new_rate)
                     {
                     // устанавливаем атрибуты
                     curr_star = document.getElementById(id);
                     parent_id = parseInt(curr_star.parentNode.id);
                     
                     // при первом пересчете ставим рейтинг для группы звезд в 0
                     if (!curr_rate[parent_id])
                     {
                     curr_rate[parent_id] = 0;
                     }
                     
                     // устанавливаем новый рейтинг в массив рейтингов и значение скрытого поля
                     if (new_rate != curr_rate[parent_id] && parseInt(new_rate) > 0)
                     {
                     curr_rate[parent_id] = new_rate;
                     
                     curr_form = document.getElementById('comment_form_0' + (parent_id != 0 ? parent_id : ''));
                     curr_form.shop_comment_grade.value = curr_rate[parent_id].charAt(curr_rate[parent_id].length - 1);
                     }
                     
                     // пересчет стилей для звезд
                     for (i = 1; i < 6; i++)
                        {
                        if (parent_id != 0)
                        {
                        j = parent_id + '' + i + '_star_' + i;
                        }
                        else
                        {
                        j = i + '_star_' + i;
                        }
                        
                        temp_obj = document.getElementById(j);
                        
                        if (new_rate == 0)
                        {
                        id = curr_rate[parent_id];
                        }
                        
                        if (parseInt(j) > parseInt(id))
                        {
                        temp_obj.className = '';
                        }
                        else
                        {
                        temp_obj.className = 'curr';
                        }
                        }
                        }
                        ]]>
                     </xsl:text>
                  </xsl:comment>
               </SCRIPT>
            
            <!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
            <xsl:variable name="parent_group_id" select="/shop/@current_group_id"/>
            
               <form method="get" action="{/shop/path}{//group[@id=$parent_group_id]/fullpath}">
               <div class="qsearch">
                  <div class="container">

                  Диапазон цен:<br />
                  <div class="selectprice">
                  <input name="price_from" size="4" type="text">
                     <xsl:if test="/shop/price_from != 0">
                        <xsl:attribute name="value">
                           <xsl:value-of disable-output-escaping="yes" select="/shop/price_from"/>
                        </xsl:attribute>
                     </xsl:if>
                  </input>&#xA0;
                  &#8212;
                  <input name="price_to" size="4" type="text">
                     <xsl:if test="/shop/price_to != 0">
                        <xsl:attribute name="value">
                           <xsl:value-of disable-output-escaping="yes" select="/shop/price_to"/>
                        </xsl:attribute>
                     </xsl:if>
                  </input>&#xA0;
                  руб.
                  </div>
                  
                  
                  <div class="сollection">
                        <p>Коллекция:</p>
                        <table cellpadding="10px" cellspacing="0">
                           <tr valign="top">
                              <xsl:apply-templates select="properties_for_group/property[property_show_kind != 0 and (shop_list_of_properties_type = 0 or shop_list_of_properties_type = 2 or shop_list_of_properties_type = 7)]"/>
                           </tr>
                        </table>
                  </div>

                  <input name="apply_filter" value="Искать" type="submit" class="submit"/>
               </div>
               
               <xsl:if test="count(properties_for_group/property[property_show_kind != 0 and (shop_list_of_properties_type = 0 or shop_list_of_properties_type = 2 or shop_list_of_properties_type = 7)]) &gt; 0">
                  <p>
                     <b>Фильтр по дополнительным свойствам товара:</b>
                  </p>
                  <table cellpadding="10px" cellspacing="0">
                     <tr valign="top">
                        <xsl:apply-templates select="properties_for_group/property[property_show_kind != 0 and (shop_list_of_properties_type = 0 or shop_list_of_properties_type = 2 or shop_list_of_properties_type = 7)]"/>
                     </tr>
                  </table>
               </xsl:if>
               
            </div>
            
            <!-- Сортировка товаров -->
            <div class="shop_block">
               <!-- Определяем ссылку с параметрами фильтра -->
               <xsl:variable name="filter">
                  <xsl:if test="/shop/apply_filter/node()">?action=apply_filter&amp;producer_id=<xsl:value-of select="/shop/producer_id"/>&amp;saller_id=<xsl:value-of select="/shop/saller_id"/>&amp;price_from=<xsl:value-of select="/shop/price_from"/>&amp;price_to=<xsl:value-of select="/shop/price_to"/>&amp;on_page=<xsl:value-of select="/shop/on_page"/>
                     <xsl:if test="/shop/property_xml/node()">
                        <!-- GET для доп. свойств -->
                        <xsl:value-of select="/shop/property_xml"/>
                     </xsl:if>
                  </xsl:if>
               </xsl:variable>
               
               <!-- Определяем первый символ вопрос или амперсанд -->
               <xsl:variable name="first_symbol">
                  <xsl:choose>
                     <xsl:when test="$filter != ''">&amp;</xsl:when>
                     <xsl:otherwise>?</xsl:otherwise>
                  </xsl:choose>
               </xsl:variable>
               
               
            </div>
            
            <!-- Определяем ссылку с параметрами фильтра -->
            <xsl:variable name="filter">
               <xsl:choose>
                  <xsl:when test="/shop/apply_filter/node()">?action=apply_filter&amp;producer_id=<xsl:value-of select="/shop/producer_id"/>&amp;saller_id=<xsl:value-of select="/shop/saller_id"/>&amp;price_from=<xsl:value-of select="/shop/price_from"/>&amp;price_to=<xsl:value-of select="/shop/price_to"/>&amp;on_page=<xsl:value-of select="/shop/on_page"/>
                     <xsl:if test="/shop/property_xml/node()">
                        <!-- GET для доп. свойств -->
                        <xsl:value-of select="/shop/property_xml"/>
                     </xsl:if>
                  </xsl:when>
                  <xsl:otherwise></xsl:otherwise>
               </xsl:choose>
            </xsl:variable>
            <!-- Определяем первый символ вопрос или амперсанд -->
            <xsl:variable name="first_symbol">
               <xsl:choose>
                  <xsl:when test="$filter != ''">&amp;</xsl:when>
                  <xsl:otherwise>?</xsl:otherwise>
               </xsl:choose>
            </xsl:variable>
            
            
            <xsl:apply-templates select="item[position()=1]" mode="single" />
            
            
            
            <xsl:if test="count(/shop/group[@id = /shop/@current_group_id]/propertys/property) > 0">
               <div style="margin: 10px 0px;">
                  <h2>Атрибуты группы товаров</h2>
                  
                  <xsl:if test="count(property[@dir_id = 0])">
                     <table border="0">
                        <xsl:apply-templates select="property[@dir_id = 0]"/>
                     </table>
                  </xsl:if>
                  
                  <xsl:apply-templates select="/shop/properties_groups_dir"/>
               </div>
            </xsl:if>
            
            <xsl:if test="count_items &gt; 0 and items_on_page &gt; 0">
               <p>
                  <xsl:call-template name="for">
                     <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:with-param name="visible_pages" select="5"/>
                  </xsl:call-template>
               </p>
               <div style="clear: both"></div>
            </xsl:if>
         </form>

            
            
         
         <div class="breadcrumbs">
         <a href="/">Главная</a>
         <span class="path_arrow"> / </span>
   
   
   
            <xsl:if test="$parent_group_id = 0">
               <a href="{/shop/path}">
                  <xsl:value-of disable-output-escaping="yes" select="/shop/name"/>
               </a>
            </xsl:if>
            
            <!-- Путь к группе -->
            <xsl:apply-templates select="//group[@id=$parent_group_id]" mode="goup_path"/>
            </div>
            
            
            <div style="clear: both"></div>
            
            <!-- Информация об ошибках -->
            <xsl:variable name="error_code" select="/shop/error"/>
            
            
            
            <div>
   
               <xsl:if test="count(property) > 0">
               <div class="pic">               
                  <!-- Свойства в корневой группе -->
                  <xsl:if test="count(property[@dir_id = 0])">
                     <ul>
                        <xsl:apply-templates select="property"/>
                     </ul>
                  </xsl:if>
                  
                  <!-- Выбираем список групп свойств -->
                  <ul class="gallery">
                  <xsl:apply-templates select="/shop/properties_items_dir"/>
                  </ul>
               </div>         
               
               </xsl:if>
   
   <div class="primaryContent">
   <div class="title">
               <h1>
                  <xsl:value-of disable-output-escaping="yes" select="name"/>
               </h1>
            
               <xsl:if test="marking_of_goods != ''">
               <p class="art"><span>Артикул: </span><strong><xsl:value-of disable-output-escaping="yes" select="marking_of_goods"/></strong></p>
               </xsl:if>
   </div>      
               
               <!-- Ссылку на добавление в корзины выводим, если:
               type = 0 - простой тип товара
               type = 1 - электронный товар, при этом остаток на складе больше 0 или -1,
               что означает неограниченное количество -->
               <xsl:if test="type = 0 or (type = 1 and (eitem_count > 0 or eitem_count = -1))">
                  <xsl:if test="@group = 593">
                     <p>
                        <input type="text" size="3" value="1" id="count_{@id}" class="product-count"/>
                        <a href="{/shop/path}cart/?action=add&amp;item_id={@id}" onclick="return AddIntoCart('/shop/', $('input:radio[name=item_id]:checked').val(), document.getElementById('count_123').value)" class="buyproduct">   Купить</a>
                     </p>
                  </xsl:if>
                  
                  <xsl:if test="@group = 586">
                     <div class="countgoods">
                        <span>Количество:</span><input type="text" size="3" value="1" id="count_{@id}" class="product-count586" />
                        <a href="{/shop/path}cart/?action=add&amp;item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}').value)" class="buyproduct">Купить</a>
                     </div>
                  </xsl:if>
               </xsl:if>
               
               
               <!-- Показываем скидки -->
               <xsl:if test="count(discount) &gt; 0">
                  <xsl:apply-templates select="discount"/>
               </xsl:if>
               
               <!-- Показываем количество на складе, если больше нуля -->
               <xsl:if test="rest &gt; 0">
                  <p>В наличии: <xsl:value-of disable-output-escaping="yes" select="rest"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="mesure"/></p>
               </xsl:if>
            <div class="clr"></div>
   
            <!-- Модификации -->
            <!--Букеты-->
            <xsl:if test="@group = 593">
               <div class="modification">
                  <xsl:if test="count(modifications/item) &gt; 0">
                     <xsl:apply-templates select="modifications/item"/>
                  </xsl:if>
               </div>
            </xsl:if>
   
               
               <!-- Описание товара -->
               <div class="description">
               <xsl:value-of disable-output-escaping="yes" select="description" />
               </div>
               <!-- Если электронный товар, выведим доступное количество -->
               <xsl:if test="type = 1">
                  <p>
                  <strong>
                     <xsl:choose>
                        <xsl:when test="eitem_count = 0">
                           Электронный товар закончился.
                        </xsl:when>
                        <xsl:when test="eitem_count = -1">
                           Электронный товар доступен для заказа.
                        </xsl:when>
                        <xsl:otherwise>
                           На складе осталось: <xsl:value-of select="eitem_count" /><xsl:text> </xsl:text><xsl:value-of select="mesure" />
                        </xsl:otherwise>
                     </xsl:choose>
                  </strong>
                  </p>
               </xsl:if>            
               
               <!-- Текст товара -->
               <p>
                  <xsl:value-of disable-output-escaping="yes" select="text"/>
               </p>
   </div>            
               <div style="clear: both;"></div>
               
            </div>
            
            <!-- Тэги для информационного элемента -->
            
            <xsl:if test="count(tying/item) &gt; 0">
               <p>
                  <b>Сопутствующие товары:</b>
               </p>
               <!-- Отображаем сопутствующие товары -->
               <xsl:apply-templates select="tying/item"/>
               <div style="clear: both;"></div>
            </xsl:if>
            
            </div>

      </xsl:template>
      
      
      <!-- Вывод раздела для свойств товара -->
      <xsl:template match="properties_items_dir">
         
         <xsl:variable name="dir_id" select="@id"/>
         
         <xsl:if test="count(/shop/item/property[@dir_id = $dir_id])">
            
               <xsl:apply-templates select="/shop/item/property[@dir_id = $dir_id]"/>
               
            
         </xsl:if>
         
         <xsl:if test="count(properties_items_dir) > 0">
            <blockquote>
               <xsl:apply-templates select="properties_items_dir"/>
            </blockquote>
         </xsl:if>
      </xsl:template>
      
      <!-- Вывод строки со значением свойства -->
      <xsl:template match="property">
         <xsl:if test="value != '' or (type = 1 and file_path != '')">
                  <xsl:choose>
                     <xsl:when test="type = 1">
                        <li class="active"><a href="{file_path}"><img src="{small_image/file_path}" alt="" /></a></li>
                     </xsl:when>
                  </xsl:choose>
         </xsl:if>
      </xsl:template>
      
      <!-- Шаблон для модификаций -->
      <xsl:template match="modifications/item">
         <div class="row">
         <xsl:if test="position() = 1">
            <label><input type="radio" name="item_id" value="{@id}" checked="checked"/><xsl:value-of select="name" /></label>
         </xsl:if>
         
         <xsl:if test="position() != 1">
            <label><input type="radio" name="item_id" value="{@id}"/><xsl:value-of select="name" /></label>
         </xsl:if>
            <div class="price">
               <xsl:value-of disable-output-escaping="yes" select="price"/>&#xA0;
               <!-- Валюта -->
               <xsl:value-of disable-output-escaping="yes" select="currency"/>
            </div>
         </div>
      </xsl:template>
      
      
      
      <!-- Шаблон для скидки -->
      <xsl:template match="discount">
         <p>
            <xsl:value-of disable-output-escaping="yes" select="name"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="value"/>%
         </p>
      </xsl:template>
      
      <xsl:template match="tying/item">
         
         <div style="clear: both">
            <p>
               <a href="{/shop/path}{fullpath}{path}/">
                  <xsl:value-of select="name"/>
               </a>
            </p>
            
            <!-- Изображение для товара, если есть -->
            <xsl:if test="small_image != ''">
               <a href="{/shop/path}{fullpath}{path}/">
                  <img src="{small_image}" align="left" style="border: 1px solid #000000; margin: 0px 5px 5px 0px"/>
               </a>
            </xsl:if>
            
            <p>
               <xsl:value-of disable-output-escaping="yes" select="description"/>
            </p>
            
            <!-- Цена товара -->
            <strong>
               <xsl:choose>
                  <xsl:when test="price != 0">
                     <xsl:value-of disable-output-escaping="yes" select="price"/>&#xA0;
                     <!-- Валюта товара -->
                     <xsl:value-of disable-output-escaping="yes" select="currency"/>
                  </xsl:when>
                  <xsl:otherwise>договорная</xsl:otherwise>
               </xsl:choose>
            </strong>
            
            <!-- Если цена со скидкой - выводим ее -->
            <xsl:if test="price!=price_tax">
               <br/>
               <font color="gray">
                  <strike>
                     <xsl:value-of disable-output-escaping="yes" select="price_tax"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="currency"/></strike>
               </font>
            </xsl:if>
            
            <!-- Если указан вес товара -->
            <xsl:if test="weight != 0">
               <br/>Вес товара: <xsl:value-of select="weight"/> <xsl:value-of select="weight_mesure"/></xsl:if>
            
            <!-- Показываем скидки -->
            <xsl:if test="count(discount) &gt; 0">
               <xsl:apply-templates select="discount"/>
            </xsl:if>
            
            <!-- Показываем количество на складе, если больше нуля -->
            <xsl:if test="rest &gt; 0">
               <br/>В наличии: <xsl:value-of disable-output-escaping="yes" select="rest"/></xsl:if>
            
            <xsl:if test="producer/name != ''">
               <br/>Производитель: <xsl:value-of disable-output-escaping="yes" select="producer/name"/></xsl:if>
         </div>
      </xsl:template>
      
      <!-- Шаблон выводит хлебные крошки -->
      <xsl:template match="group" mode="goup_path">
         <xsl:variable name="parent_id" select="@parent"/>
         
         <!-- Выбираем рекурсивно вышестоящую группу -->
         <xsl:apply-templates select="//group[@id=$parent_id]" mode="goup_path"/>
            <xsl:value-of select="name"/>
      </xsl:template>
      
   <!-- Шаблон для фильтра по дополнительным свойствам -->
   <xsl:template match="properties_for_group/property">
      
      <xsl:variable name="nodename">property_id_<xsl:value-of select="@id"/></xsl:variable>
      
      <xsl:variable name="nodename_from">property_id_<xsl:value-of select="@id"/>_from</xsl:variable>
      <xsl:variable name="nodename_to">property_id_<xsl:value-of select="@id"/>_to</xsl:variable>
      
      
         
         <xsl:if test="property_show_kind = 1">
            <!-- Отображаем поле ввода -->
            <br/>
            <input type="text" name="property_id_{@id}">
               <xsl:if test="/shop/*[name()=$nodename] != ''">
                  <xsl:attribute name="value">
                     <xsl:value-of select="/shop/*[name()=$nodename]"/>
                  </xsl:attribute>
               </xsl:if>
            </input>
         </xsl:if>
         <xsl:if test="property_show_kind = 2">
            <!-- Отображаем список -->
            <br/>
            <select name="property_id_{@id}">
               <option value="0">...</option>-->
               <xsl:apply-templates select="list_items/list_item"/>
            </select>
         </xsl:if>
         <xsl:if test="property_show_kind = 3">
            <!-- Отображаем переключатели -->
            <br/>
            <input type="radio" name="property_id_{@id}" value="0" id="id_prop_radio_{@id}_0"></input>
            <label for="id_prop_radio_{@id}_0">Любой вариант</label>
            <xsl:apply-templates select="list_items/list_item"/>
         </xsl:if>
         
         <xsl:if test=" property_show_kind = 4">
            <!-- Отображаем флажки -->
            <xsl:apply-templates select="list_items/list_item"/>
         </xsl:if>
         
         <xsl:if test=" property_show_kind = 5">
            <!-- Отображаем флажок -->
            <input type="checkbox" name="property_id_{@id}" id="property_id_{@id}" style="padding-top:4px">
               <xsl:if test="/shop/*[name()=$nodename] != ''">
                  <xsl:attribute name="checked">
                     <xsl:value-of select="/shop/*[name()=$nodename]"/>
                  </xsl:attribute>
               </xsl:if>
            </input>
            <label for="property_id_{@id}"><xsl:value-of disable-output-escaping="yes" select="property_name"/>&#xA0;</label>
            
            
            <br/>
         </xsl:if>
         
         <xsl:if test=" property_show_kind = 6">
            <!-- Отображение полей "От.. До.." -->
            <br/>
            от: <input type="text" name="property_id_{@id}_from" size="5" value="{/shop/*[name()=$nodename_from]}"/> до: <input type="text" name="property_id_{@id}_to" size="5" value="{/shop/*[name()=$nodename_to]}"/>
         </xsl:if>
         
         <xsl:if test="property_show_kind = 7">
            <!-- Отображаем список  с множественным выбором-->
            <br/>
            <select name="property_id_{@id}[]" multiple="">
               <xsl:apply-templates select="list_items/list_item"/>
            </select>
         </xsl:if>
      <xsl:if test="position() mod 6 = 0">
         <xsl:text disable-output-escaping="yes">
            &lt;/tr&gt;
            &lt;tr valign="top"&gt;
         </xsl:text>
      </xsl:if>
   </xsl:template>
      

   <!-- Шаблон для товара -->
   <xsl:template match="goods593">      
   <h1>все товары</h1>
   </xsl:template>      
      
   </xsl:stylesheet>
Авторизация