Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save r3code/bce93bae489be4e19215d947925a339f to your computer and use it in GitHub Desktop.

Select an option

Save r3code/bce93bae489be4e19215d947925a339f to your computer and use it in GitHub Desktop.
HostCMS 5 - Горячие предложения, XSLT-шаблон
<?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:template match="/">
<xsl:apply-templates select="/shop"/>
</xsl:template>
<!-- Шаблон для магазина -->
<xsl:template match="/shop">
<!-- Есть товары -->
<div class="showcase shop clear-flow">
<xsl:if test="item">
<!-- Выводим товары магазина -->
<xsl:apply-templates select="item"/>
</xsl:if>
</div><!-- /.showcase -->
</xsl:template>
<!-- Шаблон для товара. html код нужно поменять под конкретный сайт, это заготовка -->
<xsl:template match="item">
<div class="item-card">
<div class="outer">
<xsl:if test="small_image != ''">
<a class="image" href="{/shop/path}{fullpath}{path}/" title="{name}"><img
src="{small_image}"
alt="{name}" height="{small_image/@height}" width="{small_image/@width}" /></a>
<!-- <b class="hit" style="margin: {small_image/@height - 35}px 0 0 90px;">Хит!</b> -->
</xsl:if>
<div class="note">
<i></i>
<h3><xsl:if test="producer/shop_producers_list_name != ''"><span>
<xsl:value-of disable-output-escaping="yes"
select="producer/shop_producers_list_name"/></span>&#160;</xsl:if><a href="{/shop/path}{fullpath}{path}/" title="{name}">
<xsl:value-of disable-output-escaping="yes" select="name"/></a></h3>
<div class="description">
<xsl:value-of disable-output-escaping="yes" select="description"/></div>
</div><!-- /.note -->
<!-- Сюда доп. свойства товара <p>
Объем 50мл</p> -->
<span class="price">
<xsl:value-of disable-output-escaping="yes" select="price_discount"/> <xsl:value-of disable-output-escaping="yes" select="currency"/></span>
&#160;
<!-- Ссылку на добавление в корзины выводим, если:
type = 0 - простой тип товара
type = 1 - электронный товар, при этом остаток на складе больше 0 или -1,
что означает неограниченное количество -->
<xsl:if test="type = 0 or (type = 1 and (eitem_count > 0 or eitem_count = -1))">
<a class="btn-add-to-cart" href="{/shop/path}cart/?action=add&amp;item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, 1)">
Купить</a>
</xsl:if>
</div><!-- /.outer -->
</div><!-- /.item-card -->
<xsl:if test="position() mod 2 = 0">
<div class="clearfix"></div>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment