Поиск по товарам интернет магазина без модуля поиска (на Халяве)
все таки было бы интерестно посмотреть на XSL аффтора !!!!!! В СТУДИЮ,,, ПЛЗ....
Программист без пива как шампанское без пробки- быстро выдыхается.
asys-log, да было б там на что смотреть! Это же "МагазинКаталогТоваров", из которого просто выкинуто все лишнее, и добавлена форма для ввода поискового запроса.
Ну тем не менее - нате, смотрите
Вдруг там и правда что интересное есть...
Ну тем не менее - нате, смотрите
Вдруг там и правда что интересное есть...<?xml version="1.0" encoding="utf-8"?>
<!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="utf-8" 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="/">
<xsl:apply-templates select="/shop"/>
</xsl:template>
<!-- Шаблон для магазина -->
<xsl:template match="/shop">
<SCRIPT>
<xsl:comment>
<xsl:text disable-output-escaping="yes">
<![CDATA[
function set_count_mod(input_id, step)
{
var oCountMod = document.getElementById(input_id);
if (!(iCurrCount = parseInt(oCountMod.value))) {
iCurrCount = 0;
}
if (!(iCurrCount <= 0 && step < 0)) {
oCountMod.value = iCurrCount + step;
}
}
]]>
</xsl:text>
</xsl:comment>
</SCRIPT>
<!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
<xsl:variable name="parent_group_id" select="@current_group_id"/>
<h1>Поиск</h1>
<xsl:if test="count_items = 0 and search_header != ''">
<p>
<xsl:value-of select="search_header"/>
</p>
</xsl:if>
<form method="get" action="{/shop/path}search/">
<input type="text" name="src" value="{search_query}"/>
<input type="submit" value="Искать"/>
</form>
<xsl:variable name="count">1</xsl:variable>
<xsl:if test="count(item) > 0">
<xsl:apply-templates select="item"/>
<xsl:if test="count_items > items_on_page">
<xsl:variable name="count_pages" select="ceiling(count_items div items_on_page)"/>
<xsl:variable name="visible_pages" select="5"/>
<xsl:variable name="real_visible_pages">
<xsl:choose>
<xsl:when test="$count_pages < $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="current_page - (floor($real_visible_pages div 2)) < 0">
<xsl:value-of select="current_page"/>
</xsl:when>
<xsl:when test="($count_pages - current_page - 1) < floor($real_visible_pages div 2)">
<xsl:value-of select="$real_visible_pages - ($count_pages - current_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 > current_page - (floor($real_visible_pages div 2) - 1)">
<xsl:value-of select="$real_visible_pages - current_page - 1"/>
</xsl:when>
<xsl:when test="($count_pages - current_page - 1) < 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="current_page + 1 = $count_pages">
<xsl:value-of select="current_page - $real_visible_pages + 1"/>
</xsl:when>
<xsl:when test="current_page - $pre_count_page > 0">
<xsl:value-of select="current_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="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="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>
</xsl:if>
</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property">
<tr>
<td style="padding: 5px" bgcolor="#eee">
<b>
<xsl:value-of select="name"/>
</b>
</td>
<td style="padding: 5px" bgcolor="#eee">
<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="item">
<!-- Определяем цвет фона -->
<xsl:variable name="background_color">
<xsl:choose>
<xsl:when test="(position() + 1) mod 2 > 0">#f7f7f7</xsl:when>
<xsl:otherwise>#ffffff</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<table width="97%" border="0" cellpadding="0" cellspacing="0" style="padding-bottom: 7px; margin-bottom: 15px; margin-right: 10px; border-bottom: 1px solid #dadada">
<tr>
<td colspan="4" style="padding-bottom: 4px">
<!-- Название товара -->
<div style="font-size: 13pt">
<a href="{/shop/path}{fullpath}{path}/" class="cat_title">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</div>
</td>
</tr>
<tr>
<td class="cat_t" style="width: 110px" valign="top">
<!-- Изображение для товара, если есть -->
<xsl:if test="small_image!=''">
<a href="{/shop/path}{fullpath}{path}/">
<img src="{small_image}" style="border: 1px solid #DADADA"/>
</a>
</xsl:if>
</td>
<td style="vertical-align:top;padding-left:12px;">
<!-- Описание товара -->
<xsl:value-of disable-output-escaping="yes" select="description"/>
<!-- Если электронный товар, выведим доступное количество -->
<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>
<!-- Метки -->
<xsl:if test="count(tags/tag) > 0">
<p>
<img src="/hostcmsfiles/images/tags.gif" align="left" style="margin: 0px 5px -2px 0px"/>
<xsl:apply-templates select="tags/tag"/>
</p>
</xsl:if>
<!-- Продавец -->
<xsl:if test="saller!=0">
<!-- Идентификатор текущего продавца -->
<p>
<xsl:variable name="saller_id" select="saller"/>
<b>Продавец: </b>
<a href="{/shop/path}sallers/saller-{saller}/">
<xsl:value-of select="/shop/sallers/saller[@id=$saller_id]/sallers_name"/>
</a>
</p>
</xsl:if>
<!-- Если указан вес товара -->
<xsl:if test="weight != 0">
<p>Вес товара: <xsl:value-of select="weight"/> <xsl:value-of select="weight_mesure"/></p>
</xsl:if>
<!-- Скидки -->
<xsl:if test="count(discount) > 0">
<p>Скидки: <xsl:apply-templates select="discount"/></p>
</xsl:if>
<!-- Спеццены -->
<xsl:if test="count(shop_special_prices/special_price) > 0">
<p>
<b>Специальные цены:</b>
<xsl:apply-templates select="shop_special_prices/special_price"/>
</p>
</xsl:if>
<!-- Вывод цен в другой валюте -->
<xsl:variable name="price" select="price_discount"/>
<xsl:if test="count(/shop/all_currency/shop_currency) > 1 and $price > 0">
<p>
<b>Цена в других валютах:</b>
<!-- Выбираем валюты -->
<xsl:for-each select="/shop/all_currency/shop_currency">
<!-- Выводим валюты кроме текущей -->
<xsl:if test="@id != /shop/shop_currency/@id">
<br/>
<xsl:value-of select="format-number($price * shop_currency_coefficient, '### ##0,00', 'my')"/> <xsl:value-of disable-output-escaping="yes" select="shop_currency_name"/></xsl:if>
</xsl:for-each>
</p>
</xsl:if>
<!-- Модификации -->
<xsl:if test="count(modifications/item) > 0">
<b>Модификации:</b>
<table cellspacing="0" cellpadding="2">
<tr>
<td style="border-bottom: 1px solid #dadada;">Название</td>
<td style="border-bottom: 1px solid #dadada;">Цена</td>
</tr>
<xsl:apply-templates select="modifications/item"/>
</table>
</xsl:if>
<div style="margin-left: -4px; margin-top: 5px">
<xsl:variable name="var_compare_id" select="@id"/>
<input type="checkbox" name="compare_id_{@id}" id="id_compare_id_{@id}">
<label for="id_compare_id_{@id}"> <span style="border-bottom: dashed 1px">Добавить для сравнения</span> </label>
</input>
</div>
</td>
<td width="128" valign="top" style="padding-left: 30px">
<xsl:if test="property[@xml_name = 'novinka']/value != '' and property[@xml_name = 'novinka']/value = 'Да'">
<img src="/images/new.gif"/>
</xsl:if>
<xsl:if test="property[@xml_name = 'hot']/value != '' and property[@xml_name = 'hot']/value = 'Да'">
<img src="/images/hot.gif"/>
</xsl:if>
</td>
<td width="130" class="cat_price_label" style="padding-left: 10px" valign="top">
<!-- Цена товара -->
<div style="display: inline">
<xsl:choose>
<xsl:when test="price_discount != 0">
<span style="font-size: 11pt">
<b>
<xsl:variable name="price" select="price_discount"/>
<xsl:value-of select="format-number($price, '### ##0,00', 'my')"/> 
<!-- Валюта товара -->
<xsl:value-of disable-output-escaping="yes" select="currency"/>
</b>
</span>
</xsl:when>
<xsl:otherwise>
<span style="font-size: 11pt">
<b>цена договорная</b>
</span>
</xsl:otherwise>
</xsl:choose>
<br/>
<!-- Если цена со скидкой - выводим ее -->
<xsl:if test="price_tax != price_discount">
<span style="color: gray; text-decoration: line-through;">
<xsl:variable name="price_tax" select="price_tax"/>
<span style="font-size: 11pt">
<xsl:value-of select="format-number($price_tax, '### ##0,00', 'my')"/> <xsl:value-of disable-output-escaping="yes" select="currency"/></span>
</span>
<br/>
</xsl:if>
<!-- Ссылку на добавление в корзины выводим, если:
type = 0 - простой тип товара
type = 1 - электронный товар, при этом остаток на складе больше 0 или -1,
что означает неограниченное количество -->
<xsl:if test="type = 0 or (type = 1 and (eitem_count > 0 or eitem_count = -1))">
<div style="display: inline; margin-left: 3px">
<div class="left">
<input type="text" size="3" value="1" id="count_{@id}"/>
<img src="/images/map_intocart.gif" width="12" height="21" border="0" usemap="#mapInToCart{@id}" style="margin: 0 0 -6px 1px;"/>
<map name="mapInToCart{@id}">
<area shape="rect" coords="0,0,12,10" onclick="set_count_mod('count_{@id}', 1);" nohref="nohref"/>
<area shape="rect" coords="0,11,12,21" onclick="set_count_mod('count_{@id}', -1);" nohref="nohref"/>
</map>
</div>
<a href="{/shop/path}cart/?action=add&item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}').value)">
<img alt="В корзину" title="В корзину" src="/hostcmsfiles/images/cart.gif" style="margin: 0px 0px -4px 10px"/>
</a>
</div>
</xsl:if>
</div>
</td>
</tr>
</table>
</xsl:template>
<!-- /// Метки для товаров /// -->
<xsl:template match="tags/tag">
<a href="{/shop/path}tag/{tag_path_name}/" class="tag">
<xsl:value-of select="tag_name"/>
</a>
<xsl:if test="position() != last()">,</xsl:if> </xsl:template>
<!-- Шаблон для модификаций -->
<xsl:template match="modifications/item">
<tr>
<td>
<!-- Название модификации -->
<a href="{/shop/path}{fullpath}{path}/">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</td>
<td>
<!-- Цена модификации -->
<xsl:choose>
<xsl:when test="price_discount != 0">
<xsl:value-of disable-output-escaping="yes" select="price_discount"/> 
<!-- Валюта товара -->
<xsl:value-of disable-output-escaping="yes" select="currency"/>
</xsl:when>
<xsl:otherwise>договорная</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
<!-- Шаблон для скидки -->
<xsl:template match="discount">
<br/>
<xsl:value-of disable-output-escaping="yes" select="name"/> 
<xsl:value-of disable-output-escaping="yes" select="value"/>%</xsl:template>
<!-- Шаблон для спеццен -->
<xsl:template match="special_price">
<xsl:variable name="item_id" select="@item_id"/>
<br/>от <xsl:value-of select="shop_special_prices_from"/> до <xsl:value-of select="shop_special_prices_to"/> <xsl:value-of select="/shop/item[@id = $item_id]/mesure"/>
<xsl:text> </xsl:text>—
<xsl:text> </xsl:text>
<xsl:value-of select="format-number(shop_special_prices_price,'### ##0,00', 'my')"/> <xsl:value-of select="/shop/item[@id = $item_id]/currency"/>
за 1 <xsl:value-of select="/shop/item[@id = $item_id]/mesure"/></xsl:template>
<!-- Цикл для вывода строк ссылок -->
<xsl:template name="for">
<xsl:param name="items_on_page"/>
<xsl:param name="current_page"/>
<xsl:param name="pre_count_page"/>
<xsl:param name="post_count_page"/>
<xsl:param name="i" select="0"/>
<xsl:param name="count_items"/>
<xsl:param name="visible_pages"/>
<xsl:variable name="n" select="ceiling($count_items div $items_on_page)"/>
<xsl:variable name="start_page">
<xsl:choose>
<xsl:when test="$current_page + 1 = $n">
<xsl:value-of select="$current_page - $visible_pages + 1"/>
</xsl:when>
<xsl:when test="$current_page - $pre_count_page > 0">
<xsl:value-of select="$current_page - $pre_count_page"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$i = $start_page and $current_page != 0">
<span class="ctrl">← Ctrl</span>
</xsl:if>
<xsl:if test="$i = ($current_page + $post_count_page + 1) and $n != ($current_page+1)">
<span class="ctrl">Ctrl →</span>
</xsl:if>
<xsl:if test="$count_items > $items_on_page and ($current_page + $post_count_page + 1) > $i">
<!-- Заносим в переменную $parent_group_id идентификатор текущей группы -->
<xsl:variable name="parent_group_id" select="/shop/@current_group_id"/>
<!-- Путь для тэга -->
<xsl:variable name="tag_path">
<xsl:if test="count(/shop/selected_tags/tag) = 1">tag/<xsl:value-of select="/shop/selected_tags/tag/tag_path_name"/>/</xsl:if>
</xsl:variable>
<!-- Определяем группу для формирования адреса ссылки -->
<xsl:variable name="group_link" select="'search/'"/>
<!-- Определяем адрес ссылки -->
<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: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:variable name="arrows">
<xsl:choose>
<xsl:when test="(/shop/sort_by_field = 1) or (/shop/sort_by_field = 2)">
<xsl:choose>
<!-- Стрелка вверх -->
<xsl:when test="/shop/order_direction = 'ASC'">
<xsl:value-of select="$first_symbol"/>sort_by_field=<xsl:value-of select="/shop/sort_by_field"/>&order_direction=1</xsl:when>
<!-- Стрелка вниз -->
<xsl:otherwise>
<xsl:value-of select="$first_symbol"/>sort_by_field=<xsl:value-of select="/shop/sort_by_field"/>&order_direction=2</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Выводим ссылку на первую страницу -->
<xsl:if test="$current_page - $pre_count_page > 0 and $i = $start_page">
<a href="{/shop/path}{$group_link}{$tag_path}{$filter}{$arrows}" class="page_link" style="text-decoration: none;">←</a>
</xsl:if>
<!-- Ставим ссылку на страницу-->
<xsl:if test="$i != $current_page">
<xsl:if test="($current_page - $pre_count_page) <= $i and $i < $n">
<!-- Выводим ссылки на видимые страницы -->
<a href="{/shop/path}{$group_link}{$tag_path}{$number_link}{$filter}{$arrows}" class="page_link">
<xsl:value-of select="$i + 1"/>
</a>
</xsl:if>
<!-- Выводим ссылку на последнюю страницу -->
<xsl:if test="$i+1 >= ($current_page + $post_count_page + 1) and $n > ($current_page + 1 + $post_count_page)">
<!-- Выводим ссылку на последнюю страницу -->
<a href="{/shop/path}{$group_link}{$tag_path}page-{$n}/{$filter}{$arrows}" class="page_link" style="text-decoration: none;">→</a>
</xsl:if>
</xsl:if>
<!-- Ссылка на предыдущую страницу для Ctrl + влево -->
<xsl:if test="$current_page != 0 and $i = $current_page">
<xsl:variable name="prev_number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="($current_page - 1) != 0">page-<xsl:value-of select="$i"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="{/shop/path}{$group_link}{$tag_path}{$prev_number_link}{$filter}{$arrows}" id="id_prev"></a>
</xsl:if>
<!-- Ссылка на следующую страницу для Ctrl + вправо -->
<xsl:if test="($n - 1) > $current_page and $i = $current_page">
<a href="{/shop/path}{$group_link}{$tag_path}page-{$current_page+2}/{$filter}{$arrows}" id="id_next"></a>
</xsl:if>
<!-- Не ставим ссылку на страницу-->
<xsl:if test="$i = $current_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="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="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:stylesheet>
<!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="utf-8" 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="/">
<xsl:apply-templates select="/shop"/>
</xsl:template>
<!-- Шаблон для магазина -->
<xsl:template match="/shop">
<SCRIPT>
<xsl:comment>
<xsl:text disable-output-escaping="yes">
<![CDATA[
function set_count_mod(input_id, step)
{
var oCountMod = document.getElementById(input_id);
if (!(iCurrCount = parseInt(oCountMod.value))) {
iCurrCount = 0;
}
if (!(iCurrCount <= 0 && step < 0)) {
oCountMod.value = iCurrCount + step;
}
}
]]>
</xsl:text>
</xsl:comment>
</SCRIPT>
<!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
<xsl:variable name="parent_group_id" select="@current_group_id"/>
<h1>Поиск</h1>
<xsl:if test="count_items = 0 and search_header != ''">
<p>
<xsl:value-of select="search_header"/>
</p>
</xsl:if>
<form method="get" action="{/shop/path}search/">
<input type="text" name="src" value="{search_query}"/>
<input type="submit" value="Искать"/>
</form>
<xsl:variable name="count">1</xsl:variable>
<xsl:if test="count(item) > 0">
<xsl:apply-templates select="item"/>
<xsl:if test="count_items > items_on_page">
<xsl:variable name="count_pages" select="ceiling(count_items div items_on_page)"/>
<xsl:variable name="visible_pages" select="5"/>
<xsl:variable name="real_visible_pages">
<xsl:choose>
<xsl:when test="$count_pages < $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="current_page - (floor($real_visible_pages div 2)) < 0">
<xsl:value-of select="current_page"/>
</xsl:when>
<xsl:when test="($count_pages - current_page - 1) < floor($real_visible_pages div 2)">
<xsl:value-of select="$real_visible_pages - ($count_pages - current_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 > current_page - (floor($real_visible_pages div 2) - 1)">
<xsl:value-of select="$real_visible_pages - current_page - 1"/>
</xsl:when>
<xsl:when test="($count_pages - current_page - 1) < 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="current_page + 1 = $count_pages">
<xsl:value-of select="current_page - $real_visible_pages + 1"/>
</xsl:when>
<xsl:when test="current_page - $pre_count_page > 0">
<xsl:value-of select="current_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="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="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>
</xsl:if>
</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property">
<tr>
<td style="padding: 5px" bgcolor="#eee">
<b>
<xsl:value-of select="name"/>
</b>
</td>
<td style="padding: 5px" bgcolor="#eee">
<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="item">
<!-- Определяем цвет фона -->
<xsl:variable name="background_color">
<xsl:choose>
<xsl:when test="(position() + 1) mod 2 > 0">#f7f7f7</xsl:when>
<xsl:otherwise>#ffffff</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<table width="97%" border="0" cellpadding="0" cellspacing="0" style="padding-bottom: 7px; margin-bottom: 15px; margin-right: 10px; border-bottom: 1px solid #dadada">
<tr>
<td colspan="4" style="padding-bottom: 4px">
<!-- Название товара -->
<div style="font-size: 13pt">
<a href="{/shop/path}{fullpath}{path}/" class="cat_title">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</div>
</td>
</tr>
<tr>
<td class="cat_t" style="width: 110px" valign="top">
<!-- Изображение для товара, если есть -->
<xsl:if test="small_image!=''">
<a href="{/shop/path}{fullpath}{path}/">
<img src="{small_image}" style="border: 1px solid #DADADA"/>
</a>
</xsl:if>
</td>
<td style="vertical-align:top;padding-left:12px;">
<!-- Описание товара -->
<xsl:value-of disable-output-escaping="yes" select="description"/>
<!-- Если электронный товар, выведим доступное количество -->
<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>
<!-- Метки -->
<xsl:if test="count(tags/tag) > 0">
<p>
<img src="/hostcmsfiles/images/tags.gif" align="left" style="margin: 0px 5px -2px 0px"/>
<xsl:apply-templates select="tags/tag"/>
</p>
</xsl:if>
<!-- Продавец -->
<xsl:if test="saller!=0">
<!-- Идентификатор текущего продавца -->
<p>
<xsl:variable name="saller_id" select="saller"/>
<b>Продавец: </b>
<a href="{/shop/path}sallers/saller-{saller}/">
<xsl:value-of select="/shop/sallers/saller[@id=$saller_id]/sallers_name"/>
</a>
</p>
</xsl:if>
<!-- Если указан вес товара -->
<xsl:if test="weight != 0">
<p>Вес товара: <xsl:value-of select="weight"/> <xsl:value-of select="weight_mesure"/></p>
</xsl:if>
<!-- Скидки -->
<xsl:if test="count(discount) > 0">
<p>Скидки: <xsl:apply-templates select="discount"/></p>
</xsl:if>
<!-- Спеццены -->
<xsl:if test="count(shop_special_prices/special_price) > 0">
<p>
<b>Специальные цены:</b>
<xsl:apply-templates select="shop_special_prices/special_price"/>
</p>
</xsl:if>
<!-- Вывод цен в другой валюте -->
<xsl:variable name="price" select="price_discount"/>
<xsl:if test="count(/shop/all_currency/shop_currency) > 1 and $price > 0">
<p>
<b>Цена в других валютах:</b>
<!-- Выбираем валюты -->
<xsl:for-each select="/shop/all_currency/shop_currency">
<!-- Выводим валюты кроме текущей -->
<xsl:if test="@id != /shop/shop_currency/@id">
<br/>
<xsl:value-of select="format-number($price * shop_currency_coefficient, '### ##0,00', 'my')"/> <xsl:value-of disable-output-escaping="yes" select="shop_currency_name"/></xsl:if>
</xsl:for-each>
</p>
</xsl:if>
<!-- Модификации -->
<xsl:if test="count(modifications/item) > 0">
<b>Модификации:</b>
<table cellspacing="0" cellpadding="2">
<tr>
<td style="border-bottom: 1px solid #dadada;">Название</td>
<td style="border-bottom: 1px solid #dadada;">Цена</td>
</tr>
<xsl:apply-templates select="modifications/item"/>
</table>
</xsl:if>
<div style="margin-left: -4px; margin-top: 5px">
<xsl:variable name="var_compare_id" select="@id"/>
<input type="checkbox" name="compare_id_{@id}" id="id_compare_id_{@id}">
<label for="id_compare_id_{@id}"> <span style="border-bottom: dashed 1px">Добавить для сравнения</span> </label>
</input>
</div>
</td>
<td width="128" valign="top" style="padding-left: 30px">
<xsl:if test="property[@xml_name = 'novinka']/value != '' and property[@xml_name = 'novinka']/value = 'Да'">
<img src="/images/new.gif"/>
</xsl:if>
<xsl:if test="property[@xml_name = 'hot']/value != '' and property[@xml_name = 'hot']/value = 'Да'">
<img src="/images/hot.gif"/>
</xsl:if>
</td>
<td width="130" class="cat_price_label" style="padding-left: 10px" valign="top">
<!-- Цена товара -->
<div style="display: inline">
<xsl:choose>
<xsl:when test="price_discount != 0">
<span style="font-size: 11pt">
<b>
<xsl:variable name="price" select="price_discount"/>
<xsl:value-of select="format-number($price, '### ##0,00', 'my')"/> 
<!-- Валюта товара -->
<xsl:value-of disable-output-escaping="yes" select="currency"/>
</b>
</span>
</xsl:when>
<xsl:otherwise>
<span style="font-size: 11pt">
<b>цена договорная</b>
</span>
</xsl:otherwise>
</xsl:choose>
<br/>
<!-- Если цена со скидкой - выводим ее -->
<xsl:if test="price_tax != price_discount">
<span style="color: gray; text-decoration: line-through;">
<xsl:variable name="price_tax" select="price_tax"/>
<span style="font-size: 11pt">
<xsl:value-of select="format-number($price_tax, '### ##0,00', 'my')"/> <xsl:value-of disable-output-escaping="yes" select="currency"/></span>
</span>
<br/>
</xsl:if>
<!-- Ссылку на добавление в корзины выводим, если:
type = 0 - простой тип товара
type = 1 - электронный товар, при этом остаток на складе больше 0 или -1,
что означает неограниченное количество -->
<xsl:if test="type = 0 or (type = 1 and (eitem_count > 0 or eitem_count = -1))">
<div style="display: inline; margin-left: 3px">
<div class="left">
<input type="text" size="3" value="1" id="count_{@id}"/>
<img src="/images/map_intocart.gif" width="12" height="21" border="0" usemap="#mapInToCart{@id}" style="margin: 0 0 -6px 1px;"/>
<map name="mapInToCart{@id}">
<area shape="rect" coords="0,0,12,10" onclick="set_count_mod('count_{@id}', 1);" nohref="nohref"/>
<area shape="rect" coords="0,11,12,21" onclick="set_count_mod('count_{@id}', -1);" nohref="nohref"/>
</map>
</div>
<a href="{/shop/path}cart/?action=add&item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}').value)">
<img alt="В корзину" title="В корзину" src="/hostcmsfiles/images/cart.gif" style="margin: 0px 0px -4px 10px"/>
</a>
</div>
</xsl:if>
</div>
</td>
</tr>
</table>
</xsl:template>
<!-- /// Метки для товаров /// -->
<xsl:template match="tags/tag">
<a href="{/shop/path}tag/{tag_path_name}/" class="tag">
<xsl:value-of select="tag_name"/>
</a>
<xsl:if test="position() != last()">,</xsl:if> </xsl:template>
<!-- Шаблон для модификаций -->
<xsl:template match="modifications/item">
<tr>
<td>
<!-- Название модификации -->
<a href="{/shop/path}{fullpath}{path}/">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</td>
<td>
<!-- Цена модификации -->
<xsl:choose>
<xsl:when test="price_discount != 0">
<xsl:value-of disable-output-escaping="yes" select="price_discount"/> 
<!-- Валюта товара -->
<xsl:value-of disable-output-escaping="yes" select="currency"/>
</xsl:when>
<xsl:otherwise>договорная</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
<!-- Шаблон для скидки -->
<xsl:template match="discount">
<br/>
<xsl:value-of disable-output-escaping="yes" select="name"/> 
<xsl:value-of disable-output-escaping="yes" select="value"/>%</xsl:template>
<!-- Шаблон для спеццен -->
<xsl:template match="special_price">
<xsl:variable name="item_id" select="@item_id"/>
<br/>от <xsl:value-of select="shop_special_prices_from"/> до <xsl:value-of select="shop_special_prices_to"/> <xsl:value-of select="/shop/item[@id = $item_id]/mesure"/>
<xsl:text> </xsl:text>—
<xsl:text> </xsl:text>
<xsl:value-of select="format-number(shop_special_prices_price,'### ##0,00', 'my')"/> <xsl:value-of select="/shop/item[@id = $item_id]/currency"/>
за 1 <xsl:value-of select="/shop/item[@id = $item_id]/mesure"/></xsl:template>
<!-- Цикл для вывода строк ссылок -->
<xsl:template name="for">
<xsl:param name="items_on_page"/>
<xsl:param name="current_page"/>
<xsl:param name="pre_count_page"/>
<xsl:param name="post_count_page"/>
<xsl:param name="i" select="0"/>
<xsl:param name="count_items"/>
<xsl:param name="visible_pages"/>
<xsl:variable name="n" select="ceiling($count_items div $items_on_page)"/>
<xsl:variable name="start_page">
<xsl:choose>
<xsl:when test="$current_page + 1 = $n">
<xsl:value-of select="$current_page - $visible_pages + 1"/>
</xsl:when>
<xsl:when test="$current_page - $pre_count_page > 0">
<xsl:value-of select="$current_page - $pre_count_page"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$i = $start_page and $current_page != 0">
<span class="ctrl">← Ctrl</span>
</xsl:if>
<xsl:if test="$i = ($current_page + $post_count_page + 1) and $n != ($current_page+1)">
<span class="ctrl">Ctrl →</span>
</xsl:if>
<xsl:if test="$count_items > $items_on_page and ($current_page + $post_count_page + 1) > $i">
<!-- Заносим в переменную $parent_group_id идентификатор текущей группы -->
<xsl:variable name="parent_group_id" select="/shop/@current_group_id"/>
<!-- Путь для тэга -->
<xsl:variable name="tag_path">
<xsl:if test="count(/shop/selected_tags/tag) = 1">tag/<xsl:value-of select="/shop/selected_tags/tag/tag_path_name"/>/</xsl:if>
</xsl:variable>
<!-- Определяем группу для формирования адреса ссылки -->
<xsl:variable name="group_link" select="'search/'"/>
<!-- Определяем адрес ссылки -->
<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: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:variable name="arrows">
<xsl:choose>
<xsl:when test="(/shop/sort_by_field = 1) or (/shop/sort_by_field = 2)">
<xsl:choose>
<!-- Стрелка вверх -->
<xsl:when test="/shop/order_direction = 'ASC'">
<xsl:value-of select="$first_symbol"/>sort_by_field=<xsl:value-of select="/shop/sort_by_field"/>&order_direction=1</xsl:when>
<!-- Стрелка вниз -->
<xsl:otherwise>
<xsl:value-of select="$first_symbol"/>sort_by_field=<xsl:value-of select="/shop/sort_by_field"/>&order_direction=2</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Выводим ссылку на первую страницу -->
<xsl:if test="$current_page - $pre_count_page > 0 and $i = $start_page">
<a href="{/shop/path}{$group_link}{$tag_path}{$filter}{$arrows}" class="page_link" style="text-decoration: none;">←</a>
</xsl:if>
<!-- Ставим ссылку на страницу-->
<xsl:if test="$i != $current_page">
<xsl:if test="($current_page - $pre_count_page) <= $i and $i < $n">
<!-- Выводим ссылки на видимые страницы -->
<a href="{/shop/path}{$group_link}{$tag_path}{$number_link}{$filter}{$arrows}" class="page_link">
<xsl:value-of select="$i + 1"/>
</a>
</xsl:if>
<!-- Выводим ссылку на последнюю страницу -->
<xsl:if test="$i+1 >= ($current_page + $post_count_page + 1) and $n > ($current_page + 1 + $post_count_page)">
<!-- Выводим ссылку на последнюю страницу -->
<a href="{/shop/path}{$group_link}{$tag_path}page-{$n}/{$filter}{$arrows}" class="page_link" style="text-decoration: none;">→</a>
</xsl:if>
</xsl:if>
<!-- Ссылка на предыдущую страницу для Ctrl + влево -->
<xsl:if test="$current_page != 0 and $i = $current_page">
<xsl:variable name="prev_number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="($current_page - 1) != 0">page-<xsl:value-of select="$i"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="{/shop/path}{$group_link}{$tag_path}{$prev_number_link}{$filter}{$arrows}" id="id_prev"></a>
</xsl:if>
<!-- Ссылка на следующую страницу для Ctrl + вправо -->
<xsl:if test="($n - 1) > $current_page and $i = $current_page">
<a href="{/shop/path}{$group_link}{$tag_path}page-{$current_page+2}/{$filter}{$arrows}" id="id_next"></a>
</xsl:if>
<!-- Не ставим ссылку на страницу-->
<xsl:if test="$i = $current_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="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="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:stylesheet>
Заказов не беру. Консультирую редко.
ой, пасиба бальшой.. очередной РЕСПЕКТ ВАМ!!!!!!
Программист без пива как шампанское без пробки- быстро выдыхается.
evgenius2012, посмотрите вот эту тему и попробуйте адаптировать предложенное там решение.
Заказов не беру. Консультирую редко.
evgenius2012, конкретизируйте свой вопрос 
Хотя бы по какому коду вы судите - по тому что приведен здесь, на первой странице, или по тому, который по ссылке из моего предыдущего поста?
И что вы имеете в виду говоря "только для каталога"?

Хотя бы по какому коду вы судите - по тому что приведен здесь, на первой странице, или по тому, который по ссылке из моего предыдущего поста?
И что вы имеете в виду говоря "только для каталога"?
Заказов не беру. Консультирую редко.
Авторизация