Интернет-магазин: КАК вызвать фильтр в отдельном блоке?

Гость
Интернет-магазин: КАК вызвать фильтр в отдельном блоке?
Есть интернет-магазин, для категорий один XSL, для вывода фильтров - другой XSL
как в другом блоке вызвать отображение фильтра, конечно, чтобы он работал ))
#
Re: Интернет-магазин: КАК вызвать фильтр в отдельном блоке?
В продолжение к вопросу...
вызов контроллера в нужном месте:

<?php
   $Shop_Controller_Show = new Shop_Controller_Show(
      Core_Entity::factory('Shop', 3)
   );
   $Shop_Controller_Show
      ->xsl(
      Core_Entity::factory('Xsl')->getByName('catalog_filters')
   )
      ->groupsMode('all')
   // ->itemsForbiddenTags(array('text'))
      ->group(FALSE) // отменяем группы, значит передаём товары!
      ->groupsProperties(TRUE) // разрешаем доп.свойства для групп
      ->itemsProperties(TRUE) // разрешаем доп.свойства для элементов
      ->limit(0);
            
      // проверка на текущую группу
      if (is_object(Core_Page::instance()->object)
      && get_class(Core_Page::instance()->object) == 'Shop_Controller_Show')
      {
         $Shop_Controller_Show->addEntity(
           Core::factory('Core_Xml_Entity')
             ->name('current_group_id')
             ->value(intval(Core_Page::instance()->object->group))
            );
         }
      // проверка на текущую группу
         
      $Shop_Controller_Show->show();
   ?>


Шаблон XSL (тот самый catalog_filters):

<?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:template match="/shop">
      <!-- Получаем ID родительской группы и записываем в переменную $group -->
      <xsl:variable name="group" select="group"/>
      <!-- Получаем ID родительской группы и записываем в переменную $here -->
      <xsl:variable name="here" select="current_group_id"/>
      <!-- Получаем единицу -->
      <xsl:variable name="count">1</xsl:variable>
      <xsl:variable name="path">
         <xsl:choose>
            <xsl:when test="/shop//shop_group[@id=$here]/node()">
               <xsl:value-of select="/shop//shop_group[@id=$here]/url"/></xsl:when>
            <xsl:otherwise>
               <xsl:value-of select="/shop/url"/>
            </xsl:otherwise>
         </xsl:choose>
      </xsl:variable>
      
      <xsl:apply-templates select="//shop_item" />
      
      <!-- Если внутри только товары, то фильтр отображаем -->
      <xsl:choose>
         <xsl:when test="count(shop_items) != 0">
            <div id="catalog_filter">
               <h5>Фильтрация</h5>
               <!-- Показываем форму -->
               <form method="get" action="{$path}">
                  <div class="shop_filter">
                     <div class="sorting">
                        <label for="sorting">Сортировать по цене:</label>
                        <select name="sorting" onchange="$(this).parents('form:first').submit()" id="sorting">
                           <option value="1">
                              <xsl:if test="/shop/sorting = 1"><xsl:attribute name="selected">selected</xsl:attribute></xsl:if>
                              сначала дешевые
                           </option>
                           <option value="2">
                              <xsl:if test="/shop/sorting = 2"><xsl:attribute name="selected">selected</xsl:attribute></xsl:if>
                              сначала дорогие
                           </option>
                           <!-- option value="3">
                              <xsl:if test="/shop/sorting = 3"><xsl:attribute name="selected">selected</xsl:attribute></xsl:if>
                                 По названию
                           </option-->
                        </select>
                     </div>

                     <div class="price_filter">
                        <div class="price_from">
                           <label for="price_from">минимум:</label>
                           <input name="price_from" size="5" type="text" id="price_from">
                              <xsl:if test="/shop/price_from != 0">
                                 <xsl:attribute name="value"><xsl:value-of select="/shop/price_from"/></xsl:attribute>
                              </xsl:if>
                           </input>
                        </div>
                        <div class="price_to">
                           <label for="price_to">максимум:</label>
                           <input name="price_to" size="5" type="text" id="price_to">
                              <xsl:if test="/shop/price_to != 0">
                                 <xsl:attribute name="value"><xsl:value-of select="/shop/price_to"/></xsl:attribute>
                              </xsl:if>
                           </input>
                        </div>
                     </div>
                     
                     <hr />
                     
                     <!-- Фильтр по дополнительным свойствам товара: -->
                     <xsl:if test="count(shop_item_properties//property[filter != 0 and (type = 0 or type = 1 or type = 3 or type = 7)])">
                        <xsl:apply-templates select="shop_item_properties//property[filter != 0 and (type = 0 or type = 1 or type = 3 or type = 7)]" mode="propertyList"/>
                     </xsl:if>
                        
                     <xsl:apply-templates select="shop_item_properties//property[filter != 0 and (type = 0 or type = 1 or type = 3 or type = 7)]" mode="propertyList"/>
                        
                     <input name="filter" class="button" value="Применить" type="submit"/>
                  </div>
               </form>
            </div>
         </xsl:when>
         <xsl:otherwise>
            <div id="catalog_filter" class="hidden">
               <h5>Фильтрация</h5>
               <span style="display: inline-block; margin: 15px; text-align: justify;">Доступно только при условии, что в группе есть товары. Фактически, если есть что фильтровать...<br/>
               Если товаров для фильтрации нет, то этот блок будет скрыт.</span>
            </div>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>
   
   <!-- Шаблон для групп -->
   <xsl:template match="shop_group">
      <br/><b title="group {@id}">g</b>
   </xsl:template>
   
   <!-- Шаблон для элементов -->
   <xsl:template match="shop_item"><br/><b title="item">i</b></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">
            <label><xsl:value-of disable-output-escaping="yes" select="name"/></label><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">
               <select name="property_{@id}" class="filter_select">
                  <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="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>
            <label for="id_property_{../../@id}_{@id}">
               <xsl:value-of disable-output-escaping="yes" select="value"/>
            </label>
         </input>
      </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 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: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}" 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}" 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}" 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) != 0">page-<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">
            <a href="{$group_link}page-{$page+2}/{$tag_path}{$shop_producer_path}{$filter}" 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:stylesheet>


Однако! не идут товары а вместе с ними и доп.свойства (для фильтрации) и, собственно, сам фильтр не отображается.
Подскажите, в каком направлении копать,
как ПРАВИЛЬНО сделать проверку на товары и свойства...
Знания имеют свои пределы, и только глупость человеческая не знает границ...
Авторизация