Вывод текущей метки в заголовке группы товаров по этой метке

#
Вывод текущей метки в заголовке группы товаров по этой метке
Добрый день!
Есть ли где-нибудь готовое решение по данному вопросу?

Суть такова.
Например, есть товар «Платяной шкаф из МДФ с зеркалом».
У него есть метки: шкаф платяной, МДФ, эмаль, белый цвет, с зеркалом
При нажатии, к примеру, на метку шкаф платяной мы переходим к группе товаров формируемой этой меткой. Так вот эта метка должна выводиться в заголовке этой группы.
#
Re: Вывод текущей метки в заголовке группы товаров по этой метке
kamardindg,
Готового не видел, но там задача нетривиальная.
Поправить условие вывода заголовка в xsl.
Вы используете Инфо-систему или Интернет-магазин?
skype: mcross82
#
Re: Вывод текущей метки в заголовке группы товаров по этой метке
Интернет-магазин!
#
Re: Вывод текущей метки в заголовке группы товаров по этой метке
kamardindg,
Ясно, нужно поглядеть ваш XSL шаблон интернет магазина.
Выложите сюда.
skype: mcross82
#
Re: Вывод текущей метки в заголовке группы товаров по этой метке
Цитата:
Вот этот XSL-шаблон. В шаблоне, ну и соответственно, в типовой динамической странице интернет-магазина реализована функция показа схожих товаров по совпадающим меткам.


<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:hostcms="http://www.hostcms.ru/" exclude-result-prefixes="hostcms">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<xsl:decimal-format name="my" decimal-separator="," grouping-separator=" "/>
<xsl:template match="/shop">
<xsl:apply-templates select="shop_item"/>
<div class="gallery card-masonry-2 xs-card-masonry-3 md-card-masonry-4"><xsl:apply-templates select="/shop/samenews/shop_item"/></div>
</xsl:template>

<!-- Шаблон схожих товаров -->
<xsl:template match="/shop/samenews/shop_item">
<div class="card">
<a rel="index" href="{dir}{image_large}" title="Увеличить фото"><xsl:choose><xsl:when test="image_small != ''">
<img src="{dir}{image_small}" alt="{name}" class="img-thumbnail" /></xsl:when></xsl:choose></a>
<h5 class="bold"><xsl:value-of select="format-number(price, '### ##0', 'my')"/><xsl:text> </xsl:text><xsl:value-of select="currency" /><xsl:text> </xsl:text></h5>
<a href="{url}" title="Перейти в проект" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_item">
<xsl:value-of disable-output-escaping="yes" select="name"/></a></div>
</xsl:template>

<xsl:template match="shop_item">
<xsl:variable name="prev_item" select="/shop/neighboring_items/prev_item"/>
<xsl:variable name="next_item" select="/shop/neighboring_items/next_item"/>
<xsl:variable name="link_path" select="/shop/shop_group/url"/>

<ul class="pager">
<xsl:choose><xsl:when test="$prev_item != ''">
<li><a href="../{$prev_item}/">← Предыдущая</a></li></xsl:when><xsl:otherwise></xsl:otherwise></xsl:choose>
<xsl:choose><xsl:when test="$next_item != ''">
<li><a href="../{$next_item}/">Следующая →</a></li></xsl:when><xsl:otherwise></xsl:otherwise></xsl:choose>
</ul>

<h1 hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_item"><xsl:value-of disable-output-escaping="yes" select="name"/></h1>

<xsl:variable name="group" select="/shop/group"/>
<xsl:if test="/shop/message/node()">
<xsl:value-of disable-output-escaping="yes" select="/shop/message"/>
</xsl:if>
<!-- Цена товара -->
<h5 class="bold"><xsl:if test="price != 0">Цена:
<xsl:value-of select="format-number(price, '### ##0', 'my')"/><xsl:text> </xsl:text><xsl:value-of select="currency" /><xsl:text> </xsl:text>
<!-- Если цена со скидкой - выводим её -->
<xsl:if test="price_tax != price"><span class="oldPrice">
<xsl:value-of select="format-number(price_tax, '### ##0', 'my')"/><xsl:text> </xsl:text><xsl:value-of select="currency" />
</span><xsl:text> </xsl:text></xsl:if>
</xsl:if></h5>
<!-- Изображение для товара, если есть
<div class="gallery">
<div class="col-xs-6 col-sm-4 col-md-3">
<a rel="tag" href="{dir}{image_large}" title="{name}">
<img src="{dir}{image_small}" alt="{name}" class="img-thumbnail" /></a>
</div>
</div>
-->
<!-- Описание товара -->
<xsl:if test="description != ''">
<!--<div hostcms:id="{@id}" hostcms:field="description" hostcms:entity="shop_item" hostcms:type="wysiwyg">-->
<xsl:value-of disable-output-escaping="yes" select="description" />
<!--</div>-->
</xsl:if>
<!-- Текст товара -->
<xsl:if test="text != ''">
<div hostcms:id="{@id}" hostcms:field="text" hostcms:entity="shop_item" hostcms:type="wysiwyg"><xsl:value-of disable-output-escaping="yes" select="text"/></div>
</xsl:if>
<!-- Если указано отображать комментарии -->
<xsl:if test="/shop/show_comments/node() and /shop/show_comments = 1">
<!-- Отображение комментариев  -->
<xsl:if test="count(comment) &gt; 0">
<p class="h4"><a name="comments"></a>Комментарии</p>
<xsl:apply-templates select="comment"/>
</xsl:if>
</xsl:if>

<!-- Тэги для информационного элемента -->
<p class="tags both"><xsl:if test="count(tag) > 0">
<span class="octicon octicon-tag"></span><span><xsl:apply-templates select="tag"/></span>
</xsl:if></p>

<p class="both h3 bg-prim m-b">Похожие изделия - проекты</p>
</xsl:template>

<!-- Вывод строки со значением свойства -->
<xsl:template match="property_value">
<xsl:if test="value/node() and value != '' or file/node() and file != ''">
<div class="shop_property">
<xsl:variable name="property_id" select="property_id" />
<xsl:variable name="property" select="/shop/shop_item_properties//property[@id=$property_id]" />
<xsl:value-of disable-output-escaping="yes" select="$property/name"/><xsl:text>: </xsl:text>
<span><xsl:choose>
<xsl:when test="$property/type = 2">
<a href="{../dir}{file}" target="_blank"><xsl:value-of disable-output-escaping="yes" select="file_name"/></a>
</xsl:when>
<xsl:when test="$property/type = 7">
<input type="checkbox" disabled="disabled">
<xsl:if test="value = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="value"/>
</xsl:otherwise>
</xsl:choose></span>
</div>
</xsl:if>
</xsl:template>

<!-- Метки -->
<xsl:template match="tag"><a href="{/shop/url}tag/{urlencode}/" class="tag"><xsl:value-of select="name"/></a>
<xsl:if test="position() != last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:template>
<!-- Шаблон для модификаций -->
<xsl:template match="modifications/shop_item">
<li>
<!-- Название модификации -->
<a href="{url}"><xsl:value-of disable-output-escaping="yes" select="name"/></a>,
<!-- Цена модификации -->
<xsl:value-of select="price"/><xsl:text> </xsl:text><xsl:value-of disable-output-escaping="yes" select="currency"/>
</li>
</xsl:template>
<!-- Шаблон для сопутствующих товаров -->
<xsl:template match="associated/shop_item">
<li>
<!-- Название сопутствующего товара -->
<a href="{url}"><xsl:value-of disable-output-escaping="yes" select="name"/></a>,
<!-- Цена сопутствующего товара -->
<xsl:value-of select="price"/><xsl:text> </xsl:text><xsl:value-of disable-output-escaping="yes" select="currency"/>
</li>
</xsl:template>
<!-- Вывод рейтинга -->
<xsl:template name="show_average_grade">
<xsl:param name="grade" select="0"/>
<xsl:param name="const_grade" select="0"/>
<!-- Чтобы избежать зацикливания -->
<xsl:variable name="current_grade" select="$grade * 1"/>
<xsl:choose>
<!-- Если число целое -->
<xsl:when test="floor($current_grade) = $current_grade and not($const_grade &gt; ceiling($current_grade))">
<xsl:if test="$current_grade - 1 &gt; 0">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$current_grade - 1"/>
<xsl:with-param name="const_grade" select="$const_grade - 1"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$current_grade != 0">
<img src="/images/star-full.png"/>
</xsl:if>
</xsl:when>
<xsl:when test="$current_grade != 0 and not($const_grade &gt; ceiling($current_grade))">
<xsl:if test="$current_grade - 0.5 &gt; 0">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$current_grade - 0.5"/>
<xsl:with-param name="const_grade" select="$const_grade - 1"/>
</xsl:call-template>
</xsl:if>
<img src="/images/star-half.png"/>
</xsl:when>
<!-- Выводим серые звездочки, пока текущая позиция не дойдет то значения, увеличенного до целого -->
<xsl:otherwise>
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$current_grade"/>
<xsl:with-param name="const_grade" select="$const_grade - 1"/>
</xsl:call-template>
<img src="/images/star-empty.png"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Шаблон для вывода звездочек (оценки) -->
<xsl:template name="for">
<xsl:param name="i" select="0"/>
<xsl:param name="n"/>
<input type="radio" name="shop_grade" value="{$i}" id="id_shop_grade_{$i}">
<xsl:if test="/shop/shop_grade = $i">
<xsl:attribute name="checked"></xsl:attribute>
</xsl:if>
</input><xsl:text> </xsl:text>
<label for="id_shop_grade_{$i}">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$i"/>
<xsl:with-param name="const_grade" select="5"/>
</xsl:call-template>
</label>
<br/>
<xsl:if test="$n &gt; $i and $n &gt; 1">
<xsl:call-template name="for">
<xsl:with-param name="i" select="$i + 1"/>
<xsl:with-param name="n" select="$n"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Отображение комментариев -->
<xsl:template match="comment">
<!-- Отображаем комментарий, если задан текст или тема комментария -->
<xsl:if test="text != '' or subject != ''">
<a name="comment{@id}"></a>
<div class="comment" id="comment{@id}">
<xsl:if test="subject != ''">
<div class="subject" hostcms:id="{@id}" hostcms:field="subject" hostcms:entity="comment"><xsl:value-of select="subject"/></div>
</xsl:if>
<div hostcms:id="{@id}" hostcms:field="text" hostcms:entity="comment" hostcms:type="wysiwyg"><xsl:value-of select="text" disable-output-escaping="yes"/></div>
<p class="tags">
<!-- Оценка комментария -->
<xsl:if test="grade != 0">
<span><xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="grade"/>
<xsl:with-param name="const_grade" select="5"/>
</xsl:call-template></span>
</xsl:if>
<img src="/images/user.png" />
<xsl:choose>
<!-- Комментарий добавил авторизированный пользователь -->
<xsl:when test="count(siteuser) &gt; 0">
<span><a href="/users/info/{siteuser/login}/"><xsl:value-of select="siteuser/login"/></a></span>
</xsl:when>
<!-- Комментарий добавил неавторизированный пользователь -->
<xsl:otherwise>
<span><xsl:value-of select="author" /></span>
</xsl:otherwise>
</xsl:choose>
<img src="/images/calendar.png" /> <span><xsl:value-of select="datetime"/></span>
<xsl:if test="/shop/show_add_comments/node()
and ((/shop/show_add_comments = 1 and /shop/siteuser_id > 0)
or /shop/show_add_comments = 2)">
<span class="red" onclick="$('.comment_reply').hide('slow');$('#cr_{@id}').toggle('slow')">ответить</span></xsl:if>
<span class="red"><a href="{/shop/shop_item/url}#comment{@id}" title="Ссылка на комментарий">#</a></span>
</p>
</div>
<!-- Отображаем только авторизированным пользователям -->
<xsl:if test="/shop/show_add_comments/node() and ((/shop/show_add_comments = 1 and /shop/siteuser_id > 0) or /shop/show_add_comments = 2)">
<div class="comment_reply" id="cr_{@id}">
<xsl:call-template name="AddCommentForm">
<xsl:with-param name="id" select="@id"/>
</xsl:call-template>
</div>
</xsl:if>
<!-- Выбираем дочерние комментарии -->
<xsl:if test="count(comment)">
<div class="comment_sub">
<xsl:apply-templates select="comment"/>
</div>
</xsl:if>
</xsl:if>
</xsl:template>
<!-- Шаблон вывода добавления комментария -->
<xsl:template match="shop_discount"><div class="shop_discount"><xsl:value-of disable-output-escaping="yes" select="name"/><xsl:text> </xsl:text><span><xsl:value-of select="percent"/>%</span></div></xsl:template><xsl:template match="shop_group" mode="breadCrumbs"><xsl:variable name="parent_id" select="parent_id"/><xsl:apply-templates select="//shop_group[@id=$parent_id]" mode="breadCrumbs"/><xsl:if test="parent_id=0"><a href="{/shop/url}" hostcms:id="{/shop/@id}" hostcms:field="name" hostcms:entity="shop"><xsl:value-of select="/shop/name"/></a></xsl:if><span><xsl:text> → </xsl:text></span><a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of select="name"/></a></xsl:template><xsl:template name="declension"><xsl:param name="number" select="number"/><xsl:variable name="nominative">

</xsl:variable><xsl:variable name="genitive_singular"></xsl:variable><xsl:variable name="genitive_plural"></xsl:variable><xsl:variable name="last_digit"><xsl:value-of select="$number mod 10"/></xsl:variable><xsl:variable name="last_two_digits"><xsl:value-of select="$number mod 100"/></xsl:variable><xsl:choose><xsl:when test="$last_digit = 1 and $last_two_digits != 11"><xsl:value-of select="$nominative"/></xsl:when><xsl:when test="$last_digit = 2 and $last_two_digits != 12or $last_digit = 3 and $last_two_digits != 13or $last_digit = 4 and $last_two_digits != 14"><xsl:value-of select="$genitive_singular"/></xsl:when><xsl:otherwise><xsl:value-of select="$genitive_plural"/></xsl:otherwise></xsl:choose></xsl:template></xsl:stylesheet>
#
Re: Вывод текущей метки в заголовке группы товаров по этой метке
kamardindg,
Это шаблон товара, нужен магазина
skype: mcross82
#
Re: Вывод текущей метки в заголовке группы товаров по этой метке
XSL-шаблон Интернет-магазина:

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:hostcms="http://www.hostcms.ru/" exclude-result-prefixes="hostcms">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<xsl:decimal-format name="my" decimal-separator="," grouping-separator=" "/>
<xsl:template match="/"><xsl:apply-templates select="/shop"/></xsl:template>
<xsl:variable name="n" select="number(12)"/>
<xsl:template match="/shop">
<xsl:variable name="group" select="group"/>
<xsl:choose>
<xsl:when test="$group = 0">
<h1 hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop"><xsl:value-of disable-output-escaping="yes" select="name"/></h1>
<xsl:if test="count(tag) = 0 and page = 0 and description != ''">
<xsl:value-of disable-output-escaping="yes" select="description"/>
</xsl:if></xsl:when>
<xsl:otherwise>
<!--<h1 hostcms:id="{$group}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of disable-output-escaping="yes" select=".//shop_group[@id=$group]/name"/></h1>-->
<xsl:if test="page = 0 and .//shop_group[@id=$group]/description != ''">
<!--<div hostcms:id="{$group}" hostcms:field="description" hostcms:entity="shop_group" hostcms:type="wysiwyg">-->
<xsl:value-of disable-output-escaping="yes" select=".//shop_group[@id=$group]/description"/><!--</div>--></xsl:if>
</xsl:otherwise></xsl:choose>
<xsl:if test="count(tag)">
<!--<p class="h2">Метка — <strong><xsl:value-of select="tag/name"/></strong>.</p>-->
<xsl:if test="tag/description != ''">
<!--<p><xsl:value-of select="tag/description" disable-output-escaping="yes" /></p>-->
</xsl:if>
</xsl:if>
<xsl:variable name="count">1</xsl:variable>
<xsl:if test="count(tag) = 0 and count(shop_producer) = 0 and count(//shop_group[parent_id=$group]) &gt; 0">
<div class="row"><xsl:apply-templates select=".//shop_group[parent_id=$group][position() mod $n = 1]"/></div>
</xsl:if>
<xsl:if test="count(shop_item) &gt; 0 or /shop/filter = 1">
<xsl:variable name="form_tag_url"><xsl:if test="count(tag) = 1">tag/<xsl:value-of select="tag/urlencode"/>/</xsl:if></xsl:variable>
<xsl:variable name="path"><xsl:choose>
<xsl:when test="/shop//shop_group[@id=$group]/node()"><xsl:value-of select="/shop//shop_group[@id=$group]/url"/></xsl:when>
<xsl:otherwise><xsl:value-of select="/shop/url"/></xsl:otherwise>
</xsl:choose></xsl:variable>

<!-- Выводим товары магазина -->
<!--<p class="h3 text-prim bg-prim">Изделия</p>-->
<div class="gallery card-masonry-2 xs-card-masonry-3 md-card-masonry-4">
<xsl:apply-templates select="shop_item" />
</div>
</xsl:if>
</xsl:template>

<!-- Шаблон для единицы товара -->
<xsl:template match="shop_item">
<div class="card">
<a rel="tag" href="{dir}{image_large}" title="Увеличить фото"><xsl:choose><xsl:when test="image_small != ''">
<img src="{dir}{image_small}" alt="{name}" class="img-thumbnail" /></xsl:when></xsl:choose></a>
<h5 class="bold"><xsl:value-of select="format-number(price, '### ##0', 'my')"/><xsl:text> </xsl:text><xsl:value-of select="currency" /><xsl:text> </xsl:text></h5>
<a href="{url}" title="Перейти в проект" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_item">
<xsl:value-of disable-output-escaping="yes" select="name"/></a></div>
</xsl:template>

<!-- Шаблон для групп товара -->
<xsl:template match="shop_group"><xsl:for-each select=". | following-sibling::shop_group[position() &lt; $n]">
<a rel="tag" href="{url}" title="Перейти в раздел «{name}»">
<div class="col-xs-6 col-sm-4 link-img">
<xsl:if test="image_small!=''"><img src="{dir}{image_small}" alt="{name}" class="img-thumbnail" /></xsl:if>
<p class="text-uppercase text-center"><xsl:value-of disable-output-escaping="yes" select="name"/>
<span class="badge m-l"><xsl:value-of select="items_total_count"/></span></p></div></a>
</xsl:for-each></xsl:template>

<!-- Шаблон для списка товаров для сравнения -->
<xsl:template match="compare_items/compare_item">
<xsl:variable name="var_compare_id" select="."/>
<tr><td><input type="checkbox" name="del_compare_id_{compare_item_id}" id="id_del_compare_id_{compare_item_id}"/></td>
<td><a href="{/shop/url}{compare_item_url}{compare_url}/"><xsl:value-of disable-output-escaping="yes" select="compare_name"/></a></td></tr>
</xsl:template>
<!-- Шаблон для фильтра по дополнительным свойствам -->
<xsl:template match="property" mode="propertyList">
<xsl:variable name="nodename">property_<xsl:value-of select="@id"/></xsl:variable>
<xsl:variable name="nodename_from">property_<xsl:value-of select="@id"/>_from</xsl:variable>
<xsl:variable name="nodename_to">property_<xsl:value-of select="@id"/>_to</xsl:variable>
<div class="filterField">
<xsl:if test="filter != 5">
<xsl:value-of disable-output-escaping="yes" select="name"/><xsl:text> </xsl:text>
</xsl:if>
<xsl:choose>
<!-- Отображаем поле ввода -->
<xsl:when test="filter = 1">
<br/>
<input type="text" name="property_{@id}">
<xsl:if test="/shop/*[name()=$nodename] != ''">
<xsl:attribute name="value"><xsl:value-of select="/shop/*[name()=$nodename]"/></xsl:attribute>
</xsl:if>
</input>
</xsl:when>
<!-- Отображаем список -->
<xsl:when test="filter = 2">
<br/>
<select name="property_{@id}">
<option value="0">...</option>
<xsl:apply-templates select="list/list_item"/>
</select>
</xsl:when>
<!-- Отображаем переключатели -->
<xsl:when test="filter = 3">
<br/>
<div class="propertyInput">
<input type="radio" name="property_{@id}" value="0" id="id_prop_radio_{@id}_0"></input>
<label for="id_prop_radio_{@id}_0">Любой вариант</label>
<xsl:apply-templates select="list/list_item"/>
</div>
</xsl:when>
<!-- Отображаем флажки -->
<xsl:when test="filter = 4">
<div class="propertyInput">
<xsl:apply-templates select="list/list_item"/>
</div>
</xsl:when>
<!-- Отображаем флажок -->
<xsl:when test="filter = 5">
<input type="checkbox" name="property_{@id}" id="property_{@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}">
<xsl:value-of disable-output-escaping="yes" select="name"/><xsl:text> </xsl:text>
</label>
</xsl:when>
<!-- Отображение полей "от и до" -->
<xsl:when test="filter = 6">
<br/>
от: <input type="text" name="property_{@id}_from" size="2" value="{/shop/*[name()=$nodename_from]}"/> до: <input type="text" name="property_{@id}_to" size="2" value="{/shop/*[name()=$nodename_to]}"/>
</xsl:when>
<!-- Отображаем список с множественным выбором-->
<xsl:when test="filter = 7">
<br/>
<select name="property_{@id}[]" multiple="multiple">
<xsl:apply-templates select="list/list_item"/>
</select>
</xsl:when>
</xsl:choose>
</div>
</xsl:template>
<!-- Метки для товаров -->
<xsl:template match="tag">
<a href="{/shop/url}tag/{urlencode}/" class="tag"><xsl:value-of select="tag_name"/></a>
<xsl:if test="position() != last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:template>
<!-- Цикл для вывода строк ссылок -->
<xsl:template name="for">
<xsl:param name="limit"/>
<xsl:param name="page"/>
<xsl:param name="pre_count_page"/>
<xsl:param name="post_count_page"/>
<xsl:param name="i" select="0"/>
<xsl:param name="items_count"/>
<xsl:param name="visible_pages"/>
<xsl:variable name="n" select="ceiling($items_count div $limit)"/>
<xsl:variable name="start_page"><xsl:choose>
<xsl:when test="$page + 1 = $n"><xsl:value-of select="$page - $visible_pages + 1"/></xsl:when>
<xsl:when test="$page - $pre_count_page &gt; 0"><xsl:value-of select="$page - $pre_count_page"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose></xsl:variable>
<!-- ПРОЛИСТЫВАНИЕ-НАЧАЛО -->
<li class="disabled"><xsl:if test="$i = $start_page and $page != 0"><span class="ctrl">← Ctrl</span></xsl:if></li>
<li class="disabled"><xsl:if test="$i = ($page + $post_count_page + 1) and $n != ($page+1)"><span class="ctrl">Ctrl →</span></xsl:if></li>
<!-- ПРОЛИСТЫВАНИЕ-КОНЕЦ -->
<!-- Передаем фильтр -->
<xsl:variable name="filter"><xsl:if test="/shop/filter/node()">?filter=1&amp;sorting=<xsl:value-of select="/shop/sorting"/>&amp;price_from=<xsl:value-of select="/shop/price_from"/>&amp;price_to=<xsl:value-of select="/shop/price_to"/><xsl:for-each select="/shop/*"><xsl:if test="starts-with(name(), 'property_')">&amp;<xsl:value-of select="name()"/>=<xsl:value-of select="."/></xsl:if></xsl:for-each></xsl:if></xsl:variable>
<xsl:if test="$items_count &gt; $limit and ($page + $post_count_page + 1) &gt; $i">
<!-- Заносим в переменную $group идентификатор текущей группы -->
<xsl:variable name="group" select="/shop/group"/>
<!-- Путь для тэга -->
<xsl:variable name="tag_path"><xsl:if test="count(/shop/tag) != 0">tag/<xsl:value-of select="/shop/tag/urlencode"/>/</xsl:if></xsl:variable>
<!-- Путь для сравнения товара -->
<xsl:variable name="shop_producer_path"><xsl:if test="count(/shop/shop_producer)">producer-<xsl:value-of select="/shop/shop_producer/@id"/>/</xsl:if></xsl:variable>
<!-- Определяем группу для формирования адреса ссылки -->
<xsl:variable name="group_link"><xsl:choose><xsl:when test="$group != 0"><xsl:value-of select="/shop//shop_group[@id=$group]/url"/></xsl:when><xsl:otherwise><xsl:value-of select="/shop/url"/></xsl:otherwise></xsl:choose></xsl:variable>
<!-- Определяем адрес ссылки -->
<xsl:variable name="number_link"><xsl:if test="$i != 0">na-zakaz-<xsl:value-of select="$i + 1"/>/</xsl:if></xsl:variable>
<!-- Выводим ссылку на первую страницу -->
<xsl:if test="$page - $pre_count_page &gt; 0 and $i = $start_page">
<li><a href="{$group_link}{$tag_path}{$shop_producer_path}{$filter}" class="page_link1">←</a></li>
</xsl:if>
<!-- Ставим ссылку на страницу-->
<xsl:if test="$i != $page">
<xsl:if test="($page - $pre_count_page) &lt;= $i and $i &lt; $n">
<!-- Выводим ссылки на видимые страницы -->
<li><a href="{$group_link}{$number_link}{$tag_path}{$shop_producer_path}{$filter}"><xsl:value-of select="$i + 1"/></a></li>
</xsl:if>
<!-- Выводим ссылку на последнюю страницу -->
<xsl:if test="$i+1 &gt;= ($page + $post_count_page + 1) and $n &gt; ($page + 1 + $post_count_page)">
<li><a href="{$group_link}na-zakaz-{$n}/{$tag_path}{$shop_producer_path}{$filter}" class="page_link3">→</a></li>
</xsl:if>
</xsl:if>
<!-- Ссылка на предыдущую страницу для Ctrl + влево -->
<xsl:if test="$page != 0 and $i = $page">
<xsl:variable name="prev_number_link"><xsl:if test="($page) != 0">na-zakaz-<xsl:value-of select="$i"/>/</xsl:if></xsl:variable>
<a href="{$group_link}{$prev_number_link}{$tag_path}{$shop_producer_path}{$filter}" id="id_prev"></a>
</xsl:if>
<!-- Ссылка на следующую страницу для Ctrl + вправо -->
<xsl:if test="($n - 1) > $page and $i = $page">
<li class="active"><a href="{$group_link}na-zakaz-{$page+2}/{$tag_path}{$shop_producer_path}{$filter}">
<xsl:if test="$i = $page"><xsl:value-of select="$i+1"/><span class="sr-only"></span></xsl:if></a></li>
</xsl:if>
<!-- Рекурсивный вызов шаблона. НЕОБХОДИМО ПЕРЕДАВАТЬ ВСЕ НЕОБХОДИМЫЕ ПАРАМЕТРЫ! -->
<xsl:call-template name="for">
<xsl:with-param name="i" select="$i + 1"/>
<xsl:with-param name="limit" select="$limit"/>
<xsl:with-param name="page" select="$page"/>
<xsl:with-param name="items_count" select="$items_count"/>
<xsl:with-param name="pre_count_page" select="$pre_count_page"/>
<xsl:with-param name="post_count_page" select="$post_count_page"/>
<xsl:with-param name="visible_pages" select="$visible_pages"/>

</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
#
Re: Вывод текущей метки в заголовке группы товаров по этой метке
Напал на след…
Внедрил в код (XSL-шаблон Интернет-магазина) вот такое:

<h3>
<xsl:value-of select="tag" />
</h3>


Например, по метке «массив ясеня».
Но выводится коряво.
Что делать? Кто подскажет?
#
Re: Вывод текущей метки в заголовке группы товаров по этой метке
Поправил, должно работать.

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:hostcms="http://www.hostcms.ru/" exclude-result-prefixes="hostcms">
   <xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
   <xsl:decimal-format name="my" decimal-separator="," grouping-separator=" "/>
   <xsl:template match="/">
      <xsl:apply-templates select="/shop"/>
   </xsl:template>
   <xsl:variable name="n" select="number(12)"/>
   <xsl:template match="/shop">
      <xsl:variable name="group" select="group"/>
      <xsl:choose>
         <xsl:when test="$group = 0 and count(tag) = 0">
            <h1 hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop">
               <xsl:value-of disable-output-escaping="yes" select="name"/>
            </h1>
            <xsl:if test="count(tag) = 0 and page = 0 and description != ''">
               <xsl:value-of disable-output-escaping="yes" select="description"/>
            </xsl:if>
         </xsl:when>
         <xsl:when test="count(tag) != 0">
            <h1>
            <xsl:value-of disable-output-escaping="yes" select="tag/name"/>
            </h1>
         </xsl:when>
         <xsl:otherwise>
            <!--<h1 hostcms:id="{$group}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of disable-output-escaping="yes" select=".//shop_group[@id=$group]/name"/></h1>-->
            <xsl:if test="page = 0 and .//shop_group[@id=$group]/description != ''">
               <!--<div hostcms:id="{$group}" hostcms:field="description" hostcms:entity="shop_group" hostcms:type="wysiwyg">-->
               <xsl:value-of disable-output-escaping="yes" select=".//shop_group[@id=$group]/description"/>
               <!--</div>-->
            </xsl:if>
         </xsl:otherwise>
      </xsl:choose>
      <xsl:if test="count(tag)">
         <!--<p class="h2">Метка — <strong><xsl:value-of select="tag/name"/></strong>.</p>-->
         <xsl:if test="tag/description != ''">
            <!--<p><xsl:value-of select="tag/description" disable-output-escaping="yes" /></p>-->
         </xsl:if>
      </xsl:if>
      <xsl:variable name="count">1</xsl:variable>
      <xsl:if test="count(tag) = 0 and count(shop_producer) = 0 and count(//shop_group[parent_id=$group]) &gt; 0">
         <div class="row">
            <xsl:apply-templates select=".//shop_group[parent_id=$group][position() mod $n = 1]"/>
         </div>
      </xsl:if>
      <xsl:if test="count(shop_item) &gt; 0 or /shop/filter = 1">
         <xsl:variable name="form_tag_url">
            <xsl:if test="count(tag) = 1">
               tag/
               <xsl:value-of select="tag/urlencode"/>
               /
            </xsl:if>
         </xsl:variable>
         <xsl:variable name="path">
            <xsl:choose>
               <xsl:when test="/shop//shop_group[@id=$group]/node()">
                  <xsl:value-of select="/shop//shop_group[@id=$group]/url"/>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:value-of select="/shop/url"/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         <!-- Выводим товары магазина -->
         <!--<p class="h3 text-prim bg-prim">Изделия</p>-->
         <div class="gallery card-masonry-2 xs-card-masonry-3 md-card-masonry-4">
            <xsl:apply-templates select="shop_item" />
         </div>
      </xsl:if>
   </xsl:template>
   <!-- Шаблон для единицы товара -->
   <xsl:template match="shop_item">
      <div class="card">
         <a rel="tag" href="{dir}{image_large}" title="Увеличить фото">
            <xsl:choose>
               <xsl:when test="image_small != ''">
                  <img src="{dir}{image_small}" alt="{name}" class="img-thumbnail" />
               </xsl:when>
            </xsl:choose>
         </a>
         <h5 class="bold">
            <xsl:value-of select="format-number(price, '### ##0', 'my')"/>
            <xsl:text> </xsl:text>
            <xsl:value-of select="currency" />
            <xsl:text> </xsl:text>
         </h5>
         <a href="{url}" title="Перейти в проект" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_item">
            <xsl:value-of disable-output-escaping="yes" select="name"/>
         </a>
      </div>
   </xsl:template>
   <!-- Шаблон для групп товара -->
   <xsl:template match="shop_group">
      <xsl:for-each select=". | following-sibling::shop_group[position() &lt; $n]">
         <a rel="tag" href="{url}" title="Перейти в раздел «{name}»">
            <div class="col-xs-6 col-sm-4 link-img">
               <xsl:if test="image_small!=''"><img src="{dir}{image_small}" alt="{name}" class="img-thumbnail" /></xsl:if>
               <p class="text-uppercase text-center">
                  <xsl:value-of disable-output-escaping="yes" select="name"/>
                  <span class="badge m-l">
                     <xsl:value-of select="items_total_count"/>
                  </span>
               </p>
            </div>
         </a>
      </xsl:for-each>
   </xsl:template>
   <!-- Шаблон для списка товаров для сравнения -->
   <xsl:template match="compare_items/compare_item">
      <xsl:variable name="var_compare_id" select="."/>
      <tr>
         <td><input type="checkbox" name="del_compare_id_{compare_item_id}" id="id_del_compare_id_{compare_item_id}"/></td>
         <td>
            <a href="{/shop/url}{compare_item_url}{compare_url}/">
               <xsl:value-of disable-output-escaping="yes" select="compare_name"/>
            </a>
         </td>
      </tr>
   </xsl:template>
   <!-- Шаблон для фильтра по дополнительным свойствам -->
   <xsl:template match="property" mode="propertyList">
      <xsl:variable name="nodename">
         property_
         <xsl:value-of select="@id"/>
      </xsl:variable>
      <xsl:variable name="nodename_from">
         property_
         <xsl:value-of select="@id"/>
         _from
      </xsl:variable>
      <xsl:variable name="nodename_to">
         property_
         <xsl:value-of select="@id"/>
         _to
      </xsl:variable>
      <div class="filterField">
         <xsl:if test="filter != 5">
            <xsl:value-of disable-output-escaping="yes" select="name"/>
            <xsl:text> </xsl:text>
         </xsl:if>
         <xsl:choose>
            <!-- Отображаем поле ввода -->
            <xsl:when test="filter = 1">
               <br/>
               <input type="text" name="property_{@id}">
               <xsl:if test="/shop/*[name()=$nodename] != ''">
                  <xsl:attribute name="value">
                     <xsl:value-of select="/shop/*[name()=$nodename]"/>
                  </xsl:attribute>
               </xsl:if>
               </input>
            </xsl:when>
            <!-- Отображаем список -->
            <xsl:when test="filter = 2">
               <br/>
               <select name="property_{@id}">
                  <option value="0">...</option>
                  <xsl:apply-templates select="list/list_item"/>
               </select>
            </xsl:when>
            <!-- Отображаем переключатели -->
            <xsl:when test="filter = 3">
               <br/>
               <div class="propertyInput">
                  <input type="radio" name="property_{@id}" value="0" id="id_prop_radio_{@id}_0"></input>
                  <label for="id_prop_radio_{@id}_0">Любой вариант</label>
                  <xsl:apply-templates select="list/list_item"/>
               </div>
            </xsl:when>
            <!-- Отображаем флажки -->
            <xsl:when test="filter = 4">
               <div class="propertyInput">
                  <xsl:apply-templates select="list/list_item"/>
               </div>
            </xsl:when>
            <!-- Отображаем флажок -->
            <xsl:when test="filter = 5">
               <input type="checkbox" name="property_{@id}" id="property_{@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}">
                  <xsl:value-of disable-output-escaping="yes" select="name"/>
                  <xsl:text> </xsl:text>
               </label>
            </xsl:when>
            <!-- Отображение полей "от и до" -->
            <xsl:when test="filter = 6">
               <br/>
               от: <input type="text" name="property_{@id}_from" size="2" value="{/shop/*[name()=$nodename_from]}"/> до: <input type="text" name="property_{@id}_to" size="2" value="{/shop/*[name()=$nodename_to]}"/>
            </xsl:when>
            <!-- Отображаем список с множественным выбором-->
            <xsl:when test="filter = 7">
               <br/>
               <select name="property_{@id}[]" multiple="multiple">
                  <xsl:apply-templates select="list/list_item"/>
               </select>
            </xsl:when>
         </xsl:choose>
      </div>
   </xsl:template>
   <!-- Метки для товаров -->
   <xsl:template match="tag">
      <a href="{/shop/url}tag/{urlencode}/" class="tag">
         <xsl:value-of select="tag_name"/>
      </a>
      <xsl:if test="position() != last()">
         <xsl:text>, </xsl:text>
      </xsl:if>
   </xsl:template>
   <!-- Цикл для вывода строк ссылок -->
   <xsl:template name="for">
      <xsl:param name="limit"/>
      <xsl:param name="page"/>
      <xsl:param name="pre_count_page"/>
      <xsl:param name="post_count_page"/>
      <xsl:param name="i" select="0"/>
      <xsl:param name="items_count"/>
      <xsl:param name="visible_pages"/>
      <xsl:variable name="n" select="ceiling($items_count div $limit)"/>
      <xsl:variable name="start_page">
         <xsl:choose>
            <xsl:when test="$page + 1 = $n">
               <xsl:value-of select="$page - $visible_pages + 1"/>
            </xsl:when>
            <xsl:when test="$page - $pre_count_page &gt; 0">
               <xsl:value-of select="$page - $pre_count_page"/>
            </xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
         </xsl:choose>
      </xsl:variable>
      <!-- ПРОЛИСТЫВАНИЕ-НАЧАЛО -->
      <li class="disabled">
         <xsl:if test="$i = $start_page and $page != 0"><span class="ctrl">← Ctrl</span></xsl:if>
      </li>
      <li class="disabled">
         <xsl:if test="$i = ($page + $post_count_page + 1) and $n != ($page+1)"><span class="ctrl">Ctrl →</span></xsl:if>
      </li>
      <!-- ПРОЛИСТЫВАНИЕ-КОНЕЦ -->
      <!-- Передаем фильтр -->
      <xsl:variable name="filter">
         <xsl:if test="/shop/filter/node()">
            ?filter=1&amp;sorting=
            <xsl:value-of select="/shop/sorting"/>
            &amp;price_from=
            <xsl:value-of select="/shop/price_from"/>
            &amp;price_to=
            <xsl:value-of select="/shop/price_to"/>
            <xsl:for-each select="/shop/*">
               <xsl:if test="starts-with(name(), 'property_')">
                  &amp;
                  <xsl:value-of select="name()"/>
                  =
                  <xsl:value-of select="."/>
               </xsl:if>
            </xsl:for-each>
         </xsl:if>
      </xsl:variable>
      <xsl:if test="$items_count &gt; $limit and ($page + $post_count_page + 1) &gt; $i">
         <!-- Заносим в переменную $group идентификатор текущей группы -->
         <xsl:variable name="group" select="/shop/group"/>
         <!-- Путь для тэга -->
         <xsl:variable name="tag_path">
            <xsl:if test="count(/shop/tag) != 0">
               tag/
               <xsl:value-of select="/shop/tag/urlencode"/>
               /
            </xsl:if>
         </xsl:variable>
         <!-- Путь для сравнения товара -->
         <xsl:variable name="shop_producer_path">
            <xsl:if test="count(/shop/shop_producer)">
               producer-
               <xsl:value-of select="/shop/shop_producer/@id"/>
               /
            </xsl:if>
         </xsl:variable>
         <!-- Определяем группу для формирования адреса ссылки -->
         <xsl:variable name="group_link">
            <xsl:choose>
               <xsl:when test="$group != 0">
                  <xsl:value-of select="/shop//shop_group[@id=$group]/url"/>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:value-of select="/shop/url"/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         <!-- Определяем адрес ссылки -->
         <xsl:variable name="number_link">
            <xsl:if test="$i != 0">
               na-zakaz-
               <xsl:value-of select="$i + 1"/>
               /
            </xsl:if>
         </xsl:variable>
         <!-- Выводим ссылку на первую страницу -->
         <xsl:if test="$page - $pre_count_page &gt; 0 and $i = $start_page">
            <li><a href="{$group_link}{$tag_path}{$shop_producer_path}{$filter}" class="page_link1">←</a></li>
         </xsl:if>
         <!-- Ставим ссылку на страницу-->
         <xsl:if test="$i != $page">
            <xsl:if test="($page - $pre_count_page) &lt;= $i and $i &lt; $n">
               <!-- Выводим ссылки на видимые страницы -->
               <li>
                  <a href="{$group_link}{$number_link}{$tag_path}{$shop_producer_path}{$filter}">
                     <xsl:value-of select="$i + 1"/>
                  </a>
               </li>
            </xsl:if>
            <!-- Выводим ссылку на последнюю страницу -->
            <xsl:if test="$i+1 &gt;= ($page + $post_count_page + 1) and $n &gt; ($page + 1 + $post_count_page)">
               <li><a href="{$group_link}na-zakaz-{$n}/{$tag_path}{$shop_producer_path}{$filter}" class="page_link3">→</a></li>
            </xsl:if>
         </xsl:if>
         <!-- Ссылка на предыдущую страницу для Ctrl + влево -->
         <xsl:if test="$page != 0 and $i = $page">
            <xsl:variable name="prev_number_link">
               <xsl:if test="($page) != 0">
                  na-zakaz-
                  <xsl:value-of select="$i"/>
                  /
               </xsl:if>
            </xsl:variable>
            <a href="{$group_link}{$prev_number_link}{$tag_path}{$shop_producer_path}{$filter}" id="id_prev"></a>
         </xsl:if>
         <!-- Ссылка на следующую страницу для Ctrl + вправо -->
         <xsl:if test="($n - 1) > $page and $i = $page">
            <li class="active">
               <a href="{$group_link}na-zakaz-{$page+2}/{$tag_path}{$shop_producer_path}{$filter}">
                  <xsl:if test="$i = $page">
                     <xsl:value-of select="$i+1"/>
                     <span class="sr-only"></span>
                  </xsl:if>
               </a>
            </li>
         </xsl:if>
         <!-- Рекурсивный вызов шаблона. НЕОБХОДИМО ПЕРЕДАВАТЬ ВСЕ НЕОБХОДИМЫЕ ПАРАМЕТРЫ! -->
         <xsl:call-template name="for">
            <xsl:with-param name="i" select="$i + 1"/>
            <xsl:with-param name="limit" select="$limit"/>
            <xsl:with-param name="page" select="$page"/>
            <xsl:with-param name="items_count" select="$items_count"/>
            <xsl:with-param name="pre_count_page" select="$pre_count_page"/>
            <xsl:with-param name="post_count_page" select="$post_count_page"/>
            <xsl:with-param name="visible_pages" select="$visible_pages"/>
         </xsl:call-template>
      </xsl:if>
   </xsl:template>
</xsl:stylesheet>
skype: mcross82
#
Re: Вывод текущей метки в заголовке группы товаров по этой метке
Mcross, большое спасибо - всё работает отлично!
Ещё вопрос.
А как сделать, чтобы в TITLE выводилось название метки?
Авторизация