1. В XSL - шаблонах, в разделе Интернет - магазин изменяем шаблон СравнениеТоваров. Добавляем код в основной шаблон, формирующий таблицу сравнения (xsl:template match="shop"). Между кодом:
<h1>Сравнение товаров</h1>
и
<div id="sticky" class="sticky-element"> <div class="sticky-anchor"></div> <div class="sticky-content"> <table class="shop_cart shop_cart_compare"> <tr> <th>Название</th> <xsl:apply-templates select="comparing/shop_item" mode="name"/> </tr> <tr> <th>Фото</th> <xsl:apply-templates select="comparing/shop_item" mode="image"/> </tr> <tr> <th>Цена</th> <xsl:apply-templates select="comparing/shop_item" mode="price"/> </tr> </table> </div> </div>
вставить:
<xsl:if test="different = 0"> Все характеристики <a href="?diff=1">Отличия</a> </xsl:if> <xsl:if test="different = 1"> <a href="/shop/compare_items/">Все характеристики</a> Отличия </xsl:if>
2. Из шаблона формирующего свойства (xsl:template match="property") удалить код:
<!-- Есть хотя бы одно значение свойства --> <xsl:variable name="property_id" select="@id" /> <xsl:if test="count(/shop/comparing/shop_item/property_value[property_id=$property_id][not(file/node()) and value != '' or file != ''])"> <tr> <th> <xsl:value-of disable-output-escaping="yes" select="name"/><xsl:if test="description !=''"><xsl:text> </xsl:text><img src="/acvideo/css/img/tooltip.png" data-tooltip="{description}"/></xsl:if> </th> <xsl:apply-templates select="/shop/comparing/shop_item" mode="property"> <!-- Передаем через параметр ID свойства --> <xsl:with-param name="property_id" select="@id"/> </xsl:apply-templates> </tr> </xsl:if>
и вставить:
<xsl:variable name="property_id" select="@id" /> <!-- Есть хотя бы одно значение свойства --> <xsl:if test="count(/shop/comparing/shop_item/property_value[property_id=$property_id][not(file/node()) and value != '' or file != ''])"> <xsl:variable name="first_value"> <xsl:for-each select="/shop/comparing/shop_item[1]/property_value[property_id=$property_id]"> <xsl:value-of disable-output-escaping="yes" select="value"/> </xsl:for-each> </xsl:variable> <xsl:variable name="result"> <xsl:for-each select="/shop/comparing/shop_item"> <xsl:variable name="result2"> <xsl:for-each select="property_value[property_id=$property_id]"> <xsl:value-of disable-output-escaping="yes" select="value"/> </xsl:for-each> </xsl:variable> <xsl:if test="$result2 != $first_value"> 1 </xsl:if> </xsl:for-each> </xsl:variable> <xsl:if test="/shop/different = 0 or string($result) != ''"> <tr> <th> <xsl:value-of disable-output-escaping="yes" select="name"/> <xsl:if test="description !=''"> <xsl:text> </xsl:text> <img src="/acvideo/css/img/tooltip.png" data-tooltip="{description}"/> </xsl:if> </th> <xsl:apply-templates select="/shop/comparing/shop_item" mode="property"> <!-- Передаем через параметр ID свойства --> <xsl:with-param name="property_id" select="@id"/> </xsl:apply-templates> </tr> </xsl:if> </xsl:if>
3. Зайти в типовые динамические страницы, раздел интернет - магазин, и выбрать страницу сравнение товаров. В пункте код страницы между кодом:
<?php $oShop = Core_Entity::factory('Shop', Core_Array::get(Core_Page::instance()->libParams, 'shopId')); $Shop_Controller_Show = new Shop_Controller_Show($oShop);
и кодом:
$Shop_Controller_Show
->limit(0)
->group(FALSE)
->xsl(
Core_Entity::factory('Xsl')->getByName(
Core_Array::get(Core_Page::instance()->libParams, 'xsl')
)
)
->cache(FALSE)
->itemsProperties(TRUE)
->show();
Вставить код:
$different = Core_Array::getGet('diff',0);
$Shop_Controller_Show->addEntity(
Core::factory('Core_Xml_Entity')
->name('different')->value($different)
);
Страницу создал Константин Сериков 15.09.16 в 12:57