Отображение товаров и категорий товаров

#
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:template match="/">
      <xsl:apply-templates select="/shop"/>
   </xsl:template>
   
   <!-- Шаблон для магазина -->
   <xsl:template match="/shop">
      <ul class="groups">
         <li class="title">Каталог продукции</li>
         <xsl:apply-templates select="shop_group"/>
      </ul>
   </xsl:template>
   
   <!-- Шаблон для групп товара -->
   <xsl:template match="shop_group">
      <li>
         <a href="{url}">
            <xsl:if test="property_value[tag_name='new']/value = 1">
               <xsl:attribute name="class">groups__new</xsl:attribute>
            </xsl:if>
            <xsl:value-of select="name"/>
         </a>
         
         <!-- Если есть подгруппы -->
         <!-- <xsl:if test="shop_group">
            <ul class="left_menu gray_link gray" id="{@id}" style="display: none;">
               <xsl:apply-templates select="shop_group"/>
            </ul>
         </xsl:if> -->
      </li>
   </xsl:template>
   
   <!-- Шаблон для товара -->
   <xsl:template match="shop_item">
      <div class="item">
         <div class="item_img_wrap">
            <a class="item__img" href="{url}">
               <xsl:choose>
                  <xsl:when test="image_large != ''">
                     <img src="{dir}{image_large}" alt="{name}" title="{name}"/>
                  </xsl:when>
                  <xsl:otherwise>
                     <img src="/images/no-image.png" alt="{name}" title="{name}"/>
                  </xsl:otherwise>
               </xsl:choose>
            </a>
         </div>
         <p class="title">
            <a href="{url}" title="{name}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_item">
               <xsl:value-of select="name"/>
            </a>
         </p>
         <div class="description">
            <div class="descr-under-wrap">
               <div class="weight-price-wrap">
                  <div class="weight-price">
                     <div class="weight">
                        <xsl:value-of select="round(weight)"/><xsl:text>&#160;</xsl:text><xsl:value-of select="/shop/shop_measure/name"/>
                     </div>
                     <div class="price">
                     <xsl:value-of select="format-number(price, '### ##0,00', 'my')"/><xsl:text> </xsl:text><xsl:value-of select="currency"/><xsl:text> </xsl:text>
                     </div>
                  </div>
               </div>
               <div class="input-cart">
                  <div class="input-wrap">
                     <input type="number" maxlength="3" min="1" max="1000000" size="3" value="1" id="jr-{@id}"/>
                  </div>
                  <div class="addcart-wrap">
                     <xsl:if test="type = 0 or (type = 1 and (digitals > 0 or digitals = -1)) or type = 2">
                        <a href="{/shop/url}cart/" class="addcart" data-id="{@id}">
                           <div class="hits-buy">купить</div>
                        </a>
                     </xsl:if>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </xsl:template>
   
</xsl:stylesheet>



Если я его оставляю таким образом, то я вижу группы товаров по ссылке /catalog/
И на странице конкретной категории товары не появляются - вижу ту же самую категорию, в которую попал.
#
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:template match="/">
      <xsl:apply-templates select="/shop"/>
   </xsl:template>
  
   <!-- Шаблон для магазина -->
   <xsl:template match="/shop">
      <ul class="groups">
         <li class="title">Каталог продукции</li>
         <xsl:apply-templates select="shop_group"/>
      </ul>
     
         <xsl:apply-templates select="shop_item"/>
   </xsl:template>
  
   <!-- Шаблон для групп товара -->
   <xsl:template match="shop_group">
      <li>
         <a href="{url}">
            <xsl:if test="property_value[tag_name='new']/value = 1">
               <xsl:attribute name="class">groups__new</xsl:attribute>
            </xsl:if>
            <xsl:value-of select="name"/>
         </a>
      
         <!-- Если есть подгруппы -->
         <!-- <xsl:if test="shop_group">
            <ul class="left_menu gray_link gray" id="{@id}" style="display: none;">
               <xsl:apply-templates select="shop_group"/>
            </ul>
         </xsl:if> -->
      </li>
   </xsl:template>
  
   <!-- Шаблон для товара -->
   <xsl:template match="shop_item">
      <div class="item">
         <div class="item_img_wrap">
            <a class="item__img" href="{url}">
               <xsl:choose>
                  <xsl:when test="image_large != ''">
                     <img src="{dir}{image_large}" alt="{name}" title="{name}"/>
                  </xsl:when>
                  <xsl:otherwise>
                     <img src="/images/no-image.png" alt="{name}" title="{name}"/>
                  </xsl:otherwise>
               </xsl:choose>
            </a>
         </div>
         <p class="title">
            <a href="{url}" title="{name}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_item">
               <xsl:value-of select="name"/>
            </a>
         </p>
         <div class="description">
            <div class="descr-under-wrap">
               <div class="weight-price-wrap">
                  <div class="weight-price">
                     <div class="weight">
                        <xsl:value-of select="round(weight)"/><xsl:text>&#160;</xsl:text><xsl:value-of select="/shop/shop_measure/name"/>
                     </div>
                     <div class="price">
                     <xsl:value-of select="format-number(price, '### ##0,00', 'my')"/><xsl:text> </xsl:text><xsl:value-of select="currency"/><xsl:text> </xsl:text>
                     </div>
                  </div>
               </div>
               <div class="input-cart">
                  <div class="input-wrap">
                     <input type="number" maxlength="3" min="1" max="1000000" size="3" value="1" id="jr-{@id}"/>
                  </div>
                  <div class="addcart-wrap">
                     <xsl:if test="type = 0 or (type = 1 and (digitals > 0 or digitals = -1)) or type = 2">
                        <a href="{/shop/url}cart/" class="addcart" data-id="{@id}">
                           <div class="hits-buy">купить</div>
                        </a>
                     </xsl:if>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </xsl:template>
  
</xsl:stylesheet>
«Не выходи из комнаты, не совершай ошибку…»
#
Re: Отображение товаров и категорий товаров
Вижу автору поста удалось реализовать задуманное.

Но что же я делаю не так?
Код из последнего поста мне не помогает.
#
Re: Отображение товаров и категорий товаров
Нет, у меня, к сожалению, тоже не получилось (
#
Re: Отображение товаров и категорий товаров
UPD.
У меня получилось, но несколько коряво.
Т.е. на странице /catalog/ выводятся и категории, и товары. Что, в принципе, может существовать в таком виде. Но вот в конкретной категории /catalog/category/ выводится карточка с конкретной категорией, что не есть хорошо.  По идее, можно добавить через XML классы к каждой категории, и скрыть их через стили, но как-то получается коряво всё равно ...
Может, кто еще что подсказать?) Мне и товарищу taipan.gav
Вот полный код, извиняюсь за объём.
<?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(3)"/>
  
   <xsl:variable name="ajax" select="/shop/ajax"/>
  
   <xsl:template match="/shop">
      
      <!-- Получаем ID родительской группы и записываем в переменную $group -->
      <xsl:variable name="group" select="group"/>
      
      <xsl:if test="$ajax = 1">
         <xsl:apply-templates select="shop_item"/>
      </xsl:if>
      <xsl:if test="$ajax = 0">
        
         <xsl:choose>
            <xsl:when test="$group = 0">
               <h1 hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop">
                  <xsl:value-of select="name"/>
               </h1>
               <!-- Описание выводится при отсутствии фильтрации по тэгам -->
               <xsl:if test="count(tag) = 0 and page = 0 and description != ''">
                  <div hostcms:id="{@id}" hostcms:field="description" hostcms:entity="shop" hostcms:type="wysiwyg"><xsl:value-of disable-output-escaping="yes" select="description"/></div>
               </xsl:if>
            </xsl:when>
            <xsl:otherwise>
               <h1 hostcms:id="{$group}" hostcms:field="name" hostcms:entity="shop_group">
                  <xsl:value-of 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:variable name="count">1</xsl:variable>
        
         <xsl:if test="count(shop_item) &gt; 0 or /shop/filter = 1">
            <!-- дополнение пути для action, если выбрана метка -->
         <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>
            
            <form method="get" action="{$path}{$form_tag_url}">
              
               <!-- Ajax -->
               <div class="catalog ajax" id="jr-another-cat" data-offset="{limit}" data-step="{limit}">
                  <!-- Выводим товары магазина -->
                        
                              <div class="row">
        
         <xsl:apply-templates select="shop_group"/>
      </div>
                  <xsl:apply-templates select="shop_item" />
               </div>
              
               <xsl:if test="total &gt; limit">
                  <div class="ajax-more js">
                     <xsl:choose>
                        <xsl:when test="$group = 0">
                           <xsl:attribute name="onclick">return $.addNextPosts('<xsl:value-of select="url"/>', <xsl:value-of select="limit"/>, '<xsl:value-of select="$group"/>')</xsl:attribute>
                        </xsl:when>
                        <xsl:otherwise>
                           <xsl:attribute name="onclick">return $.addNextPosts('<xsl:value-of select="/shop//shop_group[@id=$group]/url"/>', <xsl:value-of select="limit"/>, '<xsl:value-of select="$group"/>')</xsl:attribute>
                        </xsl:otherwise>
                     </xsl:choose>
                     Показать еще
                  </div>
               </xsl:if>
               <!-- /Ajax -->
            </form>
         </xsl:if>
        
         <!-- Есть избранные товары -->
         <xsl:if test="favorite/shop_item">
            <p class="h1 red">Мои избранные товары</p>
            <div class="catalog">
               <!-- Выводим товары магазина -->
               <xsl:apply-templates select="favorite/shop_item[position() &lt; 4]" />
            </div>
         </xsl:if>
        
         <!-- Есть производители-->
         <xsl:if test="count(producers/shop_producer) > 0">
            <div style="margin-top: 40px">
               <h1>Производители</h1>
               <xsl:apply-templates select="producers/shop_producer"/>
            </div>
         </xsl:if>
      </xsl:if>
   </xsl:template>
  
   <!-- Шаблон для товара -->
   <xsl:template match="shop_item">
      <div class="item">
         <div class="item_img_wrap">
            <a class="item__img" href="{url}">
               <xsl:choose>
                  <xsl:when test="image_large != ''">
                     <img src="{dir}{image_large}" alt="{name}" title="{name}"/>
                  </xsl:when>
                  <xsl:otherwise>
                     <img src="/images/no-image.png" alt="{name}" title="{name}"/>
                  </xsl:otherwise>
               </xsl:choose>
            </a>
         </div>
         <p class="title">
            <a href="{url}" title="{name}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_item">
               <xsl:value-of select="name"/>
            </a>
         </p>
         <div class="description">
            <div class="descr-under-wrap">
               <div class="weight-price-wrap">
                  <div class="weight-price">
                     <div class="weight">
                        <xsl:value-of select="round(weight)"/><xsl:text>&#160;</xsl:text><xsl:value-of select="/shop/shop_measure/name"/>
                     </div>
                     <div class="price">
                     <xsl:value-of select="format-number(price, '### ##0,00', 'my')"/><xsl:text> </xsl:text><xsl:value-of select="currency"/><xsl:text> </xsl:text>
                     </div>
                  </div>
               </div>
               <div class="input-cart">
                  <div class="input-wrap">
                     <input type="number" maxlength="3" min="1" max="1000000" size="3" value="1" id="jr-{@id}"/>
                  </div>
                  <div class="addcart-wrap">
                     <xsl:if test="type = 0 or (type = 1 and (digitals > 0 or digitals = -1)) or type = 2">
                        <a href="{/shop/url}cart/" class="addcart" data-id="{@id}">
                           <div class="hits-buy">купить</div>
                        </a>
                     </xsl:if>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </xsl:template>
  
  
   <!-- Шаблон для групп товара -->
   <xsl:template match="shop_group">
      <ul class="jr-groups">
         <xsl:for-each select=". | following-sibling::shop_group[position() &lt; $n]">
            <li>

         <a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of select="name"/></a><xsl:text> </xsl:text><span class="shop_count"><xsl:value-of select="items_total_count"/></span>
            </li>
         </xsl:for-each>
      </ul>
   </xsl:template>
  
   <!-- Шаблон выводит рекурсивно ссылки на группы магазина -->
   <xsl:template match="shop_group" mode="breadCrumbs">
      <xsl:param name="parent_id" select="parent_id"/>
      
      <!-- Получаем ID родительской группы и записываем в переменную $group -->
      <xsl:param name="group" select="/shop/shop_group"/>
      
      <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 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 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">
         <legend><xsl:value-of select="name"/><xsl:text> </xsl:text></legend>
         </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 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="list/list_item">
      <xsl:if test="../../filter = 2">
         <!-- Отображаем список -->
         <xsl:variable name="nodename">property_<xsl:value-of select="../../@id"/></xsl:variable>
         <option value="{@id}">
         <xsl:if test="/shop/*[name()=$nodename] = @id"><xsl:attribute name="selected">selected</xsl:attribute></xsl:if>
            <xsl:value-of disable-output-escaping="yes" select="value"/>
         </option>
      </xsl:if>
      <xsl:if test="../../filter = 3">
         <!-- Отображаем переключатели -->
         <xsl:variable name="nodename">property_<xsl:value-of select="../../@id"/></xsl:variable>
         <br/>
         <input type="radio" name="property_{../../@id}" value="{@id}" id="id_property_{../../@id}_{@id}">
            <xsl:if test="/shop/*[name()=$nodename] = @id">
               <xsl:attribute name="checked">checked</xsl:attribute>
            </xsl:if>
         </input>
         <label for="id_property_{../../@id}_{@id}">
            <xsl:value-of disable-output-escaping="yes" select="value"/>
         </label>
      </xsl:if>
      <xsl:if test="../../filter = 4">
         <!-- Отображаем флажки -->
         <xsl:variable name="nodename">property_<xsl:value-of select="../../@id"/></xsl:variable>
         <br/>
         <input type="checkbox" value="{@id}" name="property_{../../@id}[]" id="property_{../../@id}_{@id}">
            <xsl:if test="/shop/*[name()=$nodename] = @id">
               <xsl:attribute name="checked">checked</xsl:attribute>
            </xsl:if>
            <label for="property_{../../@id}_{@id}">
               <xsl:value-of disable-output-escaping="yes" select="value"/>
            </label>
         </input>
      </xsl:if>
      <xsl:if test="../../filter = 7">
         <!-- Отображаем список -->
         <xsl:variable name="nodename">property_<xsl:value-of select="../../@id"/></xsl:variable>
         <option value="{@id}">
            <xsl:if test="/shop/*[name()=$nodename] = @id">
               <xsl:attribute name="selected">
               </xsl:attribute>
            </xsl:if>
            <xsl:value-of disable-output-escaping="yes" select="value"/>
         </option>
      </xsl:if>
   </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>
      
      <xsl:if test="$i = $start_page and $page != 0">
         <span class="ctrl">
            ← Ctrl
         </span>
      </xsl:if>
      
      <xsl:if test="$i = ($page + $post_count_page + 1) and $n != ($page+1)">
         <span class="ctrl">
            Ctrl →
         </span>
      </xsl:if>
      
      <!-- Передаем фильтр -->
<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:variable name="on_page"><xsl:if test="/shop/on_page/node() and /shop/on_page > 0"><xsl:choose><xsl:when test="/shop/filter/node()">&amp;</xsl:when><xsl:otherwise>?</xsl:otherwise></xsl:choose>on_page=<xsl:value-of select="/shop/on_page"/></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">page-<xsl:value-of select="$i + 1"/>/</xsl:if></xsl:variable>
        
         <!-- Выводим ссылку на первую страницу -->
         <xsl:if test="$page - $pre_count_page &gt; 0 and $i = $start_page">
            <a href="{$group_link}{$tag_path}{$shop_producer_path}{$filter}{$on_page}" class="page_link" style="text-decoration: none;">←</a>
         </xsl:if>
        
         <!-- Ставим ссылку на страницу-->
         <xsl:if test="$i != $page">
            <xsl:if test="($page - $pre_count_page) &lt;= $i and $i &lt; $n">
               <!-- Выводим ссылки на видимые страницы -->
               <a href="{$group_link}{$number_link}{$tag_path}{$shop_producer_path}{$filter}{$on_page}" class="page_link">
                  <xsl:value-of select="$i + 1"/>
               </a>
            </xsl:if>
            
            <!-- Выводим ссылку на последнюю страницу -->
            <xsl:if test="$i+1 &gt;= ($page + $post_count_page + 1) and $n &gt; ($page + 1 + $post_count_page)">
               <!-- Выводим ссылку на последнюю страницу -->
               <a href="{$group_link}page-{$n}/{$tag_path}{$shop_producer_path}{$filter}{$on_page}" class="page_link" style="text-decoration: none;">→</a>
            </xsl:if>
         </xsl:if>
        
         <!-- Ссылка на предыдущую страницу для Ctrl + влево -->
<xsl:if test="$page != 0 and $i = $page"><xsl:variable name="prev_number_link"><xsl:if test="$page &gt; 1">page-<xsl:value-of select="$i"/>/</xsl:if></xsl:variable><a href="{$group_link}{$prev_number_link}{$tag_path}{$shop_producer_path}{$filter}{$on_page}" id="id_prev"></a></xsl:if>
        
         <!-- Ссылка на следующую страницу для Ctrl + вправо -->
         <xsl:if test="($n - 1) > $page and $i = $page">
            <a href="{$group_link}page-{$page+2}/{$tag_path}{$shop_producer_path}{$filter}{$on_page}" id="id_next"></a>
         </xsl:if>
        
         <!-- Не ставим ссылку на страницу-->
         <xsl:if test="$i = $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="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:template match="shop_group">
        <div class="col-lg-4 col-md-2 col-sm-12 mb-4">
      <div class="shop-list-item-wrap-all">
         <div class="jr-shadow"></div>
         <div class="shop-list-item-wrap">
            <div class="shop-list-item">
               <a class="shop-list-href" href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_group">
                  <xsl:value-of select="name"/>
                  <xsl:if test="image_small!=''">
                    
                     <img src="{dir}{image_small}" align="middle"/>
                    
                  <xsl:text> </xsl:text></xsl:if>
                  <div class="btn-see">Посмотреть</div>
               </a>
            </div>
         </div>
      </div>
        </div>
   </xsl:template>
  
  
   <!-- Шаблон для фильтра производителей -->
   <xsl:template match="producers/shop_producer">
      <!-- Заносим в переменную $group идентификатор текущей группы -->
      <xsl:variable name="group" select="/shop/group"/>
      
      <!-- Определяем группу для формирования адреса ссылки -->
<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>
      
      <a href="{$group_link}?producer_id={@id}"><xsl:value-of select="name"/></a>
   </xsl:template>
</xsl:stylesheet>
#
Re: Отображение товаров и категорий товаров
Из описания не совсем понятна суть проблемы. Предоставьте скриншоты с примерами как отображается и как должно.
«Не выходи из комнаты, не совершай ошибку…»
#
Re: Отображение товаров и категорий товаров
Вот так должна отображаться страница каталога. В моём случае, /catalog/
https://gyazo.com/9e2638d3bf9bdd1204287905d8605f2c
Ниже выводятся товары. Это не критично, но убрать их было бы тоже супер:
https://gyazo.com/ee0678bff9ffa9e28580cbf5710acd25
Если же мы переходим в любую категорию , то видим товары этой категории, плюс саму категорию:
https://gyazo.com/14972906a59fc8f220dcda2bc793dfb1
А надо, чтобы в самой категории выводились исключительно товары, без дублирования категории, вот так:
https://gyazo.com/e6e56f80d08ce47cce2aee571b369ec2
Вроде бы подробно рассказал ))
#
Re: Отображение товаров и категорий товаров
Не применяйте <xsl:apply-templates select="shop_group"/> для текущей группы,  для этого добавьте ограничение в предикате <xsl:apply-templates select="shop_group[@id != $group]"/>
«Не выходи из комнаты, не совершай ошибку…»
#
Re: Отображение товаров и категорий товаров
llirik писал(а):

Всё получилось, спасибо огромное. Приведённый выше код работает: нужно только заменить  <xsl:apply-templates select="shop_group"/> на <xsl:apply-templates select="shop_group[@id != $group]"/>
#
Re: Отображение товаров и категорий товаров
llirik писал(а):
<xsl:apply-templates select="shop_group[@id != $group]"/>

Сможете подсказать, как вывести еще немного другой формат, т.е:
На странице каталога 3 группы, внутри каждой группы - подгруппы, а уже внутри подгрупп - товары.
Авторизация