параметры фильтра задаются checkbox'ами. После применения фильтра ранее выбранные checkbox'ы не восстанавливаются
в xsl-шаблоне пишу:
для формирования фильтра при выбранных checkbox'ах year1, year2, year3 в типовой динамической странице пишу:
фильтр работает, только отмеченные чекбоксы (year1, year2, year3) после применения фильтра становятся неотмеченными. Как восстановить состояние чекбоксов после применения фильтра?
<!-- Шаблон для магазина -->
<xsl:template match="/shop">
<!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
<xsl:variable name="parent_group_id" select="@current_group_id"/>
<!-- Если в находимся корне - выводим название информационной системы -->
<xsl:if test="$parent_group_id=0">
<h1>
<!-- <xsl:value-of disable-output-escaping="yes" select="name"/> -->
</h1>
</xsl:if>
<!-- Если в находимся в группе - выводим название группы -->
<xsl:if test="$parent_group_id!=0">
<h1>
<xsl:value-of disable-output-escaping="yes" select=".//group[@id=$parent_group_id]/name"/>
</h1>
</xsl:if>
<!-- Обработка выбранных тэгов -->
<xsl:if test="count(selected_tags/tag) = 1">
<h2>Метка — <strong><xsl:value-of select="selected_tags/tag/tag_name"/></strong>.</h2>
</xsl:if>
<!-- Путь к группе -->
<div class="path">
<xsl:apply-templates select=".//group[@id=$parent_group_id]" mode="goup_path"/>
</div>
<!-- Сообщение -->
<xsl:if test="message/node()">
<div id="message">
<xsl:value-of disable-output-escaping="yes" select="message" />
</div>
</xsl:if>
<xsl:if test="$parent_group_id!=0">
<!-- Метка для перехода при выводе сообщения -->
<a name="FocusAddItemMessage"></a>
<div id="ShowAddComment">
<a onclick="if (document.getElementById('AddItemForm').innerHTML == '') sendBackgroundRequest('{/shop/path}?action=show_form_add_item&group_id={$parent_group_id}', 'get', callbackfunction_showFormAddItem); else cr('AddItemForm'); return false;" href="javascript:void(0)">Добавить объявление в этот раздел</a>
</div>
<!-- Блок для вывода уведомлений о добавлении объявления или ошибке добавления -->
<div id="AddItemMessage"></div>
<div id="AddItemForm" style="display: block"></div>
</xsl:if>
<xsl:variable name="count">1</xsl:variable>
<!-- Отображение подгрупп данной группы, только если подгруппы есть и не идет фильтра по меткам -->
<xsl:if test="count(selected_tags/tag) = 0 and count(//group[@parent=$parent_group_id]) > 0">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td valign="top">
<xsl:apply-templates select="//group[@parent=$parent_group_id]">
<xsl:with-param name="style_font">shop_root_title</xsl:with-param>
</xsl:apply-templates>
</td>
</tr>
</table>
</xsl:if>
<xsl:if test="count(item) > 0 or apply_filter = 1">
<div id="body_text">
<div id="table">
<form method="get" action="./" id="AutoFilter">
<div id="rightcol">
<div class="form" >
<table width="278px" border="0" cellpadding="0" cellspacing="0">
<tr height="45px">
<td><div class="button"></div></td>
</tr>
<tr height="15px">
<td>
<center><p><strong>Поиск по параметрам</strong></p></center>
</td>
</tr>
<tr height="15px">
<td>
<p>
<!-- Производитель: 
<select name="producer_id">
<option value="0">…</option>
<xsl:apply-templates select="producerslist/producer"/>
</select> 
Продавец: 
<select name="saller_id">
<option value="0">…</option>
<xsl:apply-templates select="sallers/saller"/>
</select> 
-->
<table border="0">
<!-- доп. св-во новизна -->
<tr>
<xsl:apply-templates select="properties_for_group/property[@id=265 and 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>
<!-- доп. св-во производитель -->
<tr>
<xsl:apply-templates select="properties_for_group/property[@id=266 and 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>
<!-- доп. св-во год выпуска: от...до... -->
<tr>
<xsl:apply-templates select="properties_for_group/property[@id=269 and 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>
<!-- год: до 3 лет, 3-5 лет, старше 5 лет -->
<tr>
<td>
<input type="checkbox" name="year1" value="1"/>до 3 лет
<input type="checkbox" name="year2" value="1"/>3-5 лет
<input type="checkbox" name="year3" value="1"/>старше 5 лет
</td>
</tr>
<!-- цена: от...до... -->
<tr>
<td>
Цена от: 
<input name="price_from" size="5" 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> 
до: 
<input name="price_to" size="5" 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> 
</td>
</tr>
</table>
<!--
<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)]) > 0">
<table><tr>
<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>
-->
</p>
<p>
<span style="white-space: nowrap">Товаров на странице:</span> 
<select name="on_page">
<option value="0">…</option>
<xsl:call-template name="for_on_page">
<xsl:with-param name="i" select="10"/>
<xsl:with-param name="n" select="50"/>
</xsl:call-template>
</select> 
<div class="button">
<input name="apply_filter" value="Применить" type="submit"/>
</div>
</p>
<!-- Сортировка товаров -->
<div class="shop_block">
<!-- Определяем ссылку с параметрами фильтра -->
<xsl:variable name="filter">
<xsl:if test="/shop/apply_filter/node()">?action=apply_filter&producer_id=<xsl:value-of select="/shop/producer_id"/>&saller_id=<xsl:value-of select="/shop/saller_id"/>&price_from=<xsl:value-of select="/shop/price_from"/>&price_to=<xsl:value-of select="/shop/price_to"/>&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 != ''">&</xsl:when>
<xsl:otherwise>?</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<table border="0">
<tr>
<td>Сортировать по алфавиту</td>
<td>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 1 and /shop/order_direction = 'ASC'">
<div class="arrow_up"></div>
<img src="/hostcmsfiles/images/arrow_up.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по возрастанию"/>
</xsl:when>
<xsl:otherwise>
<div class="arrow_up_gray"></div>
<a href="{$filter}{$first_symbol}sort_by_field=1&order_direction=1" class="without_decor">
<img src="/hostcmsfiles/images/arrow_up_gray.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по возрастанию"/>
</a>
</xsl:otherwise>
</xsl:choose>
</td>
<td>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 1 and /shop/order_direction = 'DESC'">
<div class="arrow_down"></div>
<img src="/hostcmsfiles/images/arrow_down.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по убыванию"/>
</xsl:when>
<xsl:otherwise>
<div class="arrow_down_gray"></div>
<a href="{$filter}{$first_symbol}sort_by_field=1&order_direction=2" class="without_decor">
<img src="/hostcmsfiles/images/arrow_down_gray.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по убыванию"/>
</a>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
<tr>
</tr>
<tr>
<td>Сортировать по цене</td>
<td>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 2 and /shop/order_direction = 'ASC'">
<div class="arrow_up"></div>
<img src="/hostcmsfiles/images/arrow_up.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по возрастанию"/>
</xsl:when>
<xsl:otherwise>
<a href="{$filter}{$first_symbol}sort_by_field=2&order_direction=1" class="without_decor">
<img src="/hostcmsfiles/images/arrow_up_gray.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по возрастанию"/></a>
</xsl:otherwise>
</xsl:choose>
</td>
<td>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 2 and /shop/order_direction = 'DESC'">
<img src="/hostcmsfiles/images/arrow_down.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по убыванию"/>
</xsl:when>
<xsl:otherwise>
<div class="arrow_down_gray"></div>
<a href="{$filter}{$first_symbol}sort_by_field=2&order_direction=2" class="without_decor">
<img src="/hostcmsfiles/images/arrow_down_gray.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по убыванию"/>
</a>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</table>
</div>
<!-- Конец Сортировка товаров -->
</td>
</tr>
</table>
</div>
</div> <!-- rightcol -->
<div id="leftcol">
<div class="form" >
<tr height="45px"><p align="center"><strong>СПИСОК АВТО:</strong></p></tr>
<div id="table" >
<!-- Определяем ссылку с параметрами фильтра -->
<xsl:variable name="filter">
<xsl:choose>
<xsl:when test="/shop/apply_filter/node()">?action=apply_filter&producer_id=<xsl:value-of select="/shop/producer_id"/>&saller_id=<xsl:value-of select="/shop/saller_id"/>&price_from=<xsl:value-of select="/shop/price_from"/>&price_to=<xsl:value-of select="/shop/price_to"/>&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 != ''">&</xsl:when>
<xsl:otherwise>?</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:apply-templates select="item" />
<xsl:if test="count_items > 0 and items_on_page > 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>
</div>
</div>
</div>
</form>
</div>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="/shop">
<!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
<xsl:variable name="parent_group_id" select="@current_group_id"/>
<!-- Если в находимся корне - выводим название информационной системы -->
<xsl:if test="$parent_group_id=0">
<h1>
<!-- <xsl:value-of disable-output-escaping="yes" select="name"/> -->
</h1>
</xsl:if>
<!-- Если в находимся в группе - выводим название группы -->
<xsl:if test="$parent_group_id!=0">
<h1>
<xsl:value-of disable-output-escaping="yes" select=".//group[@id=$parent_group_id]/name"/>
</h1>
</xsl:if>
<!-- Обработка выбранных тэгов -->
<xsl:if test="count(selected_tags/tag) = 1">
<h2>Метка — <strong><xsl:value-of select="selected_tags/tag/tag_name"/></strong>.</h2>
</xsl:if>
<!-- Путь к группе -->
<div class="path">
<xsl:apply-templates select=".//group[@id=$parent_group_id]" mode="goup_path"/>
</div>
<!-- Сообщение -->
<xsl:if test="message/node()">
<div id="message">
<xsl:value-of disable-output-escaping="yes" select="message" />
</div>
</xsl:if>
<xsl:if test="$parent_group_id!=0">
<!-- Метка для перехода при выводе сообщения -->
<a name="FocusAddItemMessage"></a>
<div id="ShowAddComment">
<a onclick="if (document.getElementById('AddItemForm').innerHTML == '') sendBackgroundRequest('{/shop/path}?action=show_form_add_item&group_id={$parent_group_id}', 'get', callbackfunction_showFormAddItem); else cr('AddItemForm'); return false;" href="javascript:void(0)">Добавить объявление в этот раздел</a>
</div>
<!-- Блок для вывода уведомлений о добавлении объявления или ошибке добавления -->
<div id="AddItemMessage"></div>
<div id="AddItemForm" style="display: block"></div>
</xsl:if>
<xsl:variable name="count">1</xsl:variable>
<!-- Отображение подгрупп данной группы, только если подгруппы есть и не идет фильтра по меткам -->
<xsl:if test="count(selected_tags/tag) = 0 and count(//group[@parent=$parent_group_id]) > 0">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td valign="top">
<xsl:apply-templates select="//group[@parent=$parent_group_id]">
<xsl:with-param name="style_font">shop_root_title</xsl:with-param>
</xsl:apply-templates>
</td>
</tr>
</table>
</xsl:if>
<xsl:if test="count(item) > 0 or apply_filter = 1">
<div id="body_text">
<div id="table">
<form method="get" action="./" id="AutoFilter">
<div id="rightcol">
<div class="form" >
<table width="278px" border="0" cellpadding="0" cellspacing="0">
<tr height="45px">
<td><div class="button"></div></td>
</tr>
<tr height="15px">
<td>
<center><p><strong>Поиск по параметрам</strong></p></center>
</td>
</tr>
<tr height="15px">
<td>
<p>
<!-- Производитель: 
<select name="producer_id">
<option value="0">…</option>
<xsl:apply-templates select="producerslist/producer"/>
</select> 
Продавец: 
<select name="saller_id">
<option value="0">…</option>
<xsl:apply-templates select="sallers/saller"/>
</select> 
-->
<table border="0">
<!-- доп. св-во новизна -->
<tr>
<xsl:apply-templates select="properties_for_group/property[@id=265 and 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>
<!-- доп. св-во производитель -->
<tr>
<xsl:apply-templates select="properties_for_group/property[@id=266 and 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>
<!-- доп. св-во год выпуска: от...до... -->
<tr>
<xsl:apply-templates select="properties_for_group/property[@id=269 and 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>
<!-- год: до 3 лет, 3-5 лет, старше 5 лет -->
<tr>
<td>
<input type="checkbox" name="year1" value="1"/>до 3 лет
<input type="checkbox" name="year2" value="1"/>3-5 лет
<input type="checkbox" name="year3" value="1"/>старше 5 лет
</td>
</tr>
<!-- цена: от...до... -->
<tr>
<td>
Цена от: 
<input name="price_from" size="5" 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> 
до: 
<input name="price_to" size="5" 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> 
</td>
</tr>
</table>
<!--
<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)]) > 0">
<table><tr>
<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>
-->
</p>
<p>
<span style="white-space: nowrap">Товаров на странице:</span> 
<select name="on_page">
<option value="0">…</option>
<xsl:call-template name="for_on_page">
<xsl:with-param name="i" select="10"/>
<xsl:with-param name="n" select="50"/>
</xsl:call-template>
</select> 
<div class="button">
<input name="apply_filter" value="Применить" type="submit"/>
</div>
</p>
<!-- Сортировка товаров -->
<div class="shop_block">
<!-- Определяем ссылку с параметрами фильтра -->
<xsl:variable name="filter">
<xsl:if test="/shop/apply_filter/node()">?action=apply_filter&producer_id=<xsl:value-of select="/shop/producer_id"/>&saller_id=<xsl:value-of select="/shop/saller_id"/>&price_from=<xsl:value-of select="/shop/price_from"/>&price_to=<xsl:value-of select="/shop/price_to"/>&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 != ''">&</xsl:when>
<xsl:otherwise>?</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<table border="0">
<tr>
<td>Сортировать по алфавиту</td>
<td>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 1 and /shop/order_direction = 'ASC'">
<div class="arrow_up"></div>
<img src="/hostcmsfiles/images/arrow_up.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по возрастанию"/>
</xsl:when>
<xsl:otherwise>
<div class="arrow_up_gray"></div>
<a href="{$filter}{$first_symbol}sort_by_field=1&order_direction=1" class="without_decor">
<img src="/hostcmsfiles/images/arrow_up_gray.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по возрастанию"/>
</a>
</xsl:otherwise>
</xsl:choose>
</td>
<td>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 1 and /shop/order_direction = 'DESC'">
<div class="arrow_down"></div>
<img src="/hostcmsfiles/images/arrow_down.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по убыванию"/>
</xsl:when>
<xsl:otherwise>
<div class="arrow_down_gray"></div>
<a href="{$filter}{$first_symbol}sort_by_field=1&order_direction=2" class="without_decor">
<img src="/hostcmsfiles/images/arrow_down_gray.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по убыванию"/>
</a>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
<tr>
</tr>
<tr>
<td>Сортировать по цене</td>
<td>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 2 and /shop/order_direction = 'ASC'">
<div class="arrow_up"></div>
<img src="/hostcmsfiles/images/arrow_up.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по возрастанию"/>
</xsl:when>
<xsl:otherwise>
<a href="{$filter}{$first_symbol}sort_by_field=2&order_direction=1" class="without_decor">
<img src="/hostcmsfiles/images/arrow_up_gray.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по возрастанию"/></a>
</xsl:otherwise>
</xsl:choose>
</td>
<td>
<xsl:choose>
<xsl:when test="/shop/sort_by_field = 2 and /shop/order_direction = 'DESC'">
<img src="/hostcmsfiles/images/arrow_down.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по убыванию"/>
</xsl:when>
<xsl:otherwise>
<div class="arrow_down_gray"></div>
<a href="{$filter}{$first_symbol}sort_by_field=2&order_direction=2" class="without_decor">
<img src="/hostcmsfiles/images/arrow_down_gray.png" style="filter: alpha(opacity=0); margin: 0px 0px -4px 0px" alt="по убыванию"/>
</a>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</table>
</div>
<!-- Конец Сортировка товаров -->
</td>
</tr>
</table>
</div>
</div> <!-- rightcol -->
<div id="leftcol">
<div class="form" >
<tr height="45px"><p align="center"><strong>СПИСОК АВТО:</strong></p></tr>
<div id="table" >
<!-- Определяем ссылку с параметрами фильтра -->
<xsl:variable name="filter">
<xsl:choose>
<xsl:when test="/shop/apply_filter/node()">?action=apply_filter&producer_id=<xsl:value-of select="/shop/producer_id"/>&saller_id=<xsl:value-of select="/shop/saller_id"/>&price_from=<xsl:value-of select="/shop/price_from"/>&price_to=<xsl:value-of select="/shop/price_to"/>&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 != ''">&</xsl:when>
<xsl:otherwise>?</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:apply-templates select="item" />
<xsl:if test="count_items > 0 and items_on_page > 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>
</div>
</div>
</div>
</form>
</div>
</div>
</xsl:if>
</xsl:template>
для формирования фильтра при выбранных checkbox'ах year1, year2, year3 в типовой динамической странице пишу:
/* Ограничиваем по годам: до 3-х лет */
if (to_int($_GET['year1']) > 0)
{
$element['type'] = 1; // 0 - основное св-во, 1 - дополнительное
$element['property_id'] = '269';
$element['prefix'] = 'AND'; // префикс
$element['if'] = '>'; // Условие
// определяем дату
$d = to_int(date('Y'))-3;
// получаем id элемента списка
$lists = singleton('lists');
$lists_id = '46';
$list_item_value = $d;
$row=$lists->GetListItemIfIssetValue($lists_id, $list_item_value);
$element['value'] = $row['lists_items_id'];
// print_r($row);
$element['sufix'] = '';
$param['select'][] = $element;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
/* Ограничиваем по годам: от 3-х до 5-ти лет */
if (to_int($_GET['year2']) > 0)
{
$element['type'] = 1; // 0 - основное св-во, 1 - дополнительное
$element['property_id'] = '269';
$element['prefix'] = 'AND'; // префикс
$element['if'] = '<'; // Условие
// определяем дату
$d = to_int(date('Y'))-2;
// получаем id элемента списка
$lists = singleton('lists');
$lists_id = '46';
$list_item_value = $d;
$row=$lists->GetListItemIfIssetValue($lists_id, $list_item_value);
$element['value'] = $row['lists_items_id'];
$element['sufix'] = '';
$param['select'][] = $element;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
if (to_int($_GET['year2']) > 0)
{
$element['type'] = 1; // 0 - основное св-во, 1 - дополнительное
$element['property_id'] = '269';
$element['prefix'] = 'AND'; // префикс
$element['if'] = '>'; // Условие
// определяем дату
$d = to_int(date('Y'))-6;
// получаем id элемента списка
$lists = singleton('lists');
$lists_id = '46';
$list_item_value = $d;
$row=$lists->GetListItemIfIssetValue($lists_id, $list_item_value);
$element['value'] = $row['lists_items_id'];
$element['sufix'] = '';
$param['select'][] = $element;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
/* Ограничиваем по годам: свыше 5-ти лет */
if (to_int($_GET['year3']) > 0)
{
$element['type'] = 1; // 0 - основное св-во, 1 - дополнительное
$element['property_id'] = '269';
$element['prefix'] = 'AND'; // префикс
$element['if'] = '<'; // Условие
// определяем дату
$d = to_int(date('Y'))-5;
// получаем id элемента списка
$lists = singleton('lists');
$lists_id = '46';
$list_item_value = $d;
$row=$lists->GetListItemIfIssetValue($lists_id, $list_item_value);
$element['value'] = $row['lists_items_id'];
$element['sufix'] = '';
$param['select'][] = $element;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
if (to_int($_GET['year1']) > 0)
{
$element['type'] = 1; // 0 - основное св-во, 1 - дополнительное
$element['property_id'] = '269';
$element['prefix'] = 'AND'; // префикс
$element['if'] = '>'; // Условие
// определяем дату
$d = to_int(date('Y'))-3;
// получаем id элемента списка
$lists = singleton('lists');
$lists_id = '46';
$list_item_value = $d;
$row=$lists->GetListItemIfIssetValue($lists_id, $list_item_value);
$element['value'] = $row['lists_items_id'];
// print_r($row);
$element['sufix'] = '';
$param['select'][] = $element;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
/* Ограничиваем по годам: от 3-х до 5-ти лет */
if (to_int($_GET['year2']) > 0)
{
$element['type'] = 1; // 0 - основное св-во, 1 - дополнительное
$element['property_id'] = '269';
$element['prefix'] = 'AND'; // префикс
$element['if'] = '<'; // Условие
// определяем дату
$d = to_int(date('Y'))-2;
// получаем id элемента списка
$lists = singleton('lists');
$lists_id = '46';
$list_item_value = $d;
$row=$lists->GetListItemIfIssetValue($lists_id, $list_item_value);
$element['value'] = $row['lists_items_id'];
$element['sufix'] = '';
$param['select'][] = $element;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
if (to_int($_GET['year2']) > 0)
{
$element['type'] = 1; // 0 - основное св-во, 1 - дополнительное
$element['property_id'] = '269';
$element['prefix'] = 'AND'; // префикс
$element['if'] = '>'; // Условие
// определяем дату
$d = to_int(date('Y'))-6;
// получаем id элемента списка
$lists = singleton('lists');
$lists_id = '46';
$list_item_value = $d;
$row=$lists->GetListItemIfIssetValue($lists_id, $list_item_value);
$element['value'] = $row['lists_items_id'];
$element['sufix'] = '';
$param['select'][] = $element;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
/* Ограничиваем по годам: свыше 5-ти лет */
if (to_int($_GET['year3']) > 0)
{
$element['type'] = 1; // 0 - основное св-во, 1 - дополнительное
$element['property_id'] = '269';
$element['prefix'] = 'AND'; // префикс
$element['if'] = '<'; // Условие
// определяем дату
$d = to_int(date('Y'))-5;
// получаем id элемента списка
$lists = singleton('lists');
$lists_id = '46';
$list_item_value = $d;
$row=$lists->GetListItemIfIssetValue($lists_id, $list_item_value);
$element['value'] = $row['lists_items_id'];
$element['sufix'] = '';
$param['select'][] = $element;
/* Применять фильтр */
$external_propertys['apply_filter'] = true;
}
фильтр работает, только отмеченные чекбоксы (year1, year2, year3) после применения фильтра становятся неотмеченными. Как восстановить состояние чекбоксов после применения фильтра?
Передать в xml имена отмеченных состояния всех чекбоксов, и в xslt в момент их прорисовки проверять наличие значение узлов с этими именами в xml, если они есть оно равно единице то добавлять к чекбоксу атрибут checked
UPD: Так будет лучше, и больше соответствует примеру, приведенному ниже.
UPD: Так будет лучше, и больше соответствует примеру, приведенному ниже.
Заказов не беру. Консультирую редко.
Ну как-то так:
В ТДС
// дзен :)
$external_propertys['year1'] = isset($_GET['year1']);
$external_propertys['year2'] = isset($_GET['year2']);
$external_propertys['year3'] = isset($_GET['year3']);
// конец дзена :))
/* Ограничиваем по годам: до 3-х лет */
if (to_int($_GET['year1']) > 0) {
$element['type'] = 1; // 0 - основное св-во, 1 - дополнительное
$element['property_id'] = '269';
$element['prefix'] = 'AND'; // префикс
// ну и дальше все как у вас...
И в XSLT (только сам фрагмент с чекбоксами)
В ТДС
// дзен :)
$external_propertys['year1'] = isset($_GET['year1']);
$external_propertys['year2'] = isset($_GET['year2']);
$external_propertys['year3'] = isset($_GET['year3']);
// конец дзена :))
/* Ограничиваем по годам: до 3-х лет */
if (to_int($_GET['year1']) > 0) {
$element['type'] = 1; // 0 - основное св-во, 1 - дополнительное
$element['property_id'] = '269';
$element['prefix'] = 'AND'; // префикс
// ну и дальше все как у вас...
И в XSLT (только сам фрагмент с чекбоксами)
<td>
<input type="checkbox" name="year1"value="1">
<xsl:if test="/shop/year1 = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>до 3 лет
<input type="checkbox" name="year2"value="1">
<xsl:if test="/shop/year2 = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>3-5 лет
<input type="checkbox" name="year3"value="1">
<xsl:if test="/shop/year3 = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>старше 5 лет
</td>
<input type="checkbox" name="year1"
<xsl:if test="/shop/year1 = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>до 3 лет
<input type="checkbox" name="year2"
<xsl:if test="/shop/year2 = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>3-5 лет
<input type="checkbox" name="year3"
<xsl:if test="/shop/year3 = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>старше 5 лет
</td>
Заказов не беру. Консультирую редко.
когда в типовой динамической странице пишу:
<input type="checkbox" name="year1">
<xsl:if test="/shop/year1 = 1">
<xsl:attribute name="checked"></xsl:attribute>
</xsl:if>
</input>
до 3 лет
, то в браузере отображается просто пустая страница. Убираю кусок: <xsl:if test="/shop/year1 = 1">
<xsl:attribute name="checked"></xsl:attribute>
</xsl:if>
</input>
до 3 лет
<xsl:if test="/shop/year1 = 1">
<xsl:attribute name="checked"></xsl:attribute>
</xsl:if>
и форма отображается нормально<xsl:attribute name="checked"></xsl:attribute>
</xsl:if>
sielski писал(а):
то в браузере отображается просто пустая страница.
Это вы невнимательно код вставляете - у вас где-то получается нарушение иерархии тегов (какой-то не закрыт, или наоборот, лишний закрывающий). Попробуйте еще раз.
Заказов не беру. Консультирую редко.
И вот тут тоже ошибка: не
<xsl:attribute name="checked"></xsl:attribute>
a <xsl:attribute name="checked">checked</xsl:attribute>
Заказов не беру. Консультирую редко.
попутно ещё вопрос можно? Почему когда я ставлю фильтр по какому-то из доп. свойств, -- например, выбираю признак "новые" (доп. свойство "Новизна": тип -- список, способ отображения -- флажки), -- выбираю чекбокс year1 (до 3-х лет) и применяю фильтр -- то ничего не выбирается? Хотя должно бы. То же самое с доп. свойством "Производитель" (тип -- список, способ отображения -- списком).
Авторизация
