Выдана 127001 лицензия

Доработка стандартного шаблона поиска

Доработка стандартного шаблона поиска
#
p34
Здравствуйте! Имеется стандартный шаблон поиска товара, ищет только по артикулу, хотелось бы получить совет что дополнить, для поиска по названию товара.



<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet SYSTEM "lang://60">
<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"/>
   
   <xslecimal-format name="my" decimal-separator="," grouping-separator=" "/>
   
   <xsl:template match="/">
      <xsl:apply-templates select="/shop"/>
   </xsl:template>
   
   <xsl:template match="/shop">
      <h1>Результат поиска</h1><!--  -->
      <!-- Форма поиска
      <form method="get" action="/finder/" class="search form-horizontal">
         <div class="input-group">
            <input id="search" type="text" size="50" name="text" value="{search_text}" maxlength="200" class="input_buttom_search form-control margin-right-5"/><xsl:text> </xsl:text>
            <div class="actions input-group-btn actions-search">
               <button class="btn btn-primary" type="submit" name="submit" value="submit">Найти</button>
            </div>
         </div>
      </form> -->
      <div class="cms-search">
         <xsl:if test="search_error and search_error != ''">
            <div id="error">
               <xsl:value-of disable-output-escaping="yes" select="search_error"/>
            </div>
         </xsl:if>
         
         <xsl:if test="count(shop_item) = 0 and (not(search_error) or search_error = '')">
            <div id="error">По вашему запросу ничего не найдено.</div>
         </xsl:if>
      </div>
      
      <xsl:if test="count(shop_item) &gt; 0">
         
         <!-- Выводим товары магазина -->
         <div class="row products-grid margin-top-20">
            <xsl:apply-templates select="shop_item" />
         </div>
         
         <xsl:if test="total &gt; 0 and limit &gt; 0 and total &gt; limit">
            
            <xsl:variable name="count_pages" select="ceiling(total div limit)"/>
            
            <xsl:variable name="visible_pages" select="5"/>
            
            <xsl:variable name="real_visible_pages">
               <xsl:choose>
                  <xsl:when test="$count_pages &lt; $visible_pages">
                     <xsl:value-of select="$count_pages"/>
                  </xsl:when>
                  <xsl:otherwise>
                     <xsl:value-of select="$visible_pages"/>
                  </xsl:otherwise>
               </xsl:choose>
            </xsl:variable>
            
            <!-- Считаем количество выводимых ссылок перед текущим элементом -->
            <xsl:variable name="pre_count_page">
               <xsl:choose>
                  <xsl:when test="page - (floor($real_visible_pages div 2)) &lt; 0">
                     <xsl:value-of select="page"/>
                  </xsl:when>
                  <xsl:when test="($count_pages - page - 1) &lt; floor($real_visible_pages div 2)">
                     <xsl:value-of select="$real_visible_pages - ($count_pages - page - 1) - 1"/>
                  </xsl:when>
                  <xsl:otherwise>
                     <xsl:choose>
                        <xsl:when test="round($real_visible_pages div 2) = $real_visible_pages div 2">
                           <xsl:value-of select="floor($real_visible_pages div 2) - 1"/>
                        </xsl:when>
                        <xsl:otherwise>
                           <xsl:value-of select="floor($real_visible_pages div 2)"/>
                        </xsl:otherwise>
                     </xsl:choose>
                  </xsl:otherwise>
               </xsl:choose>
            </xsl:variable>
            
            <!-- Считаем количество выводимых ссылок после текущего элемента -->
            <xsl:variable name="post_count_page">
               <xsl:choose>
                  <xsl:when test="0 &gt; page - (floor($real_visible_pages div 2) - 1)">
                     <xsl:value-of select="$real_visible_pages - page - 1"/>
                  </xsl:when>
                  <xsl:when test="($count_pages - page - 1) &lt; floor($real_visible_pages div 2)">
                     <xsl:value-of select="$real_visible_pages - $pre_count_page - 1"/>
                  </xsl:when>
                  <xsl:otherwise>
                     <xsl:value-of select="$real_visible_pages - $pre_count_page - 1"/>
                  </xsl:otherwise>
               </xsl:choose>
            </xsl:variable>
            
            <xsl:variable name="i">
               <xsl:choose>
                  <xsl:when test="page + 1 = $count_pages">
                     <xsl:value-of select="page - $real_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>
            
            <div class="row">
               <div class="col-xs-12 text-align-center">
                  <nav>
                     <ul class="pagination">
                        <xsl:call-template name="for">
                           <xsl:with-param name="limit" select="limit"/>
                           <xsl:with-param name="page" select="page"/>
                           <xsl:with-param name="items_count" select="total"/>
                           <xsl:with-param name="i" select="$i"/>
                           <xsl:with-param name="post_count_page" select="$post_count_page"/>
                           <xsl:with-param name="pre_count_page" select="$pre_count_page"/>
                           <xsl:with-param name="visible_pages" select="$real_visible_pages"/>
                        </xsl:call-template>
                     </ul>
                  </nav>
               </div>
            </div>
         </xsl:if>
         
      </xsl:if>
      
   </xsl:template>
   
   <!-- Шаблон для товара -->
   <xsl:template match="shop_item">
      <div class="col-xs-12 col-sm-12 col-md-6 col-lg-3 item">
         <div class="grid_wrap">
            <div class="product-image">
               
               <a href="{url}" title="{name}">
                  <xsl:text disable-output-escaping="yes">&lt;span>&lt;/span></xsl:text>
                  <xsl:choose>
                     <xsl:when test="image_small != ''">
                        <img src="{dir}{image_small}" alt="{name}" class="img-responsive"/>
                     </xsl:when>
                     <xsl:otherwise>
                        <img src="/images/default-image.png"/>
                     </xsl:otherwise>
                  </xsl:choose>
               </a>
               
               <xsl:if test="discount != 0">
                  <span class="product-label">
                     <span class="label-sale">
                        <span class="sale-text">-<xsl:value-of disable-output-escaping="yes" select="round(shop_discount/percent)"/>%</span>
                     </span>
                  </span>
               </xsl:if>
               
               <xsl:variable name="shop_item_id" select="@id" />
               <div class="product-buttons">
                  <div class="product-wishlist">
                     <span onclick="return $.addFavorite('{/shop/url}', {@id}, this)">
                        <xsl:if test="/shop/favorite/shop_item[@id = $shop_item_id]/node()">
                           <xsl:attribute name="class">favorite-current</xsl:attribute>
                        </xsl:if>
                        <i class="fa fa-heart-o"></i>
                     </span>
                  </div>
                  <div class="product-compare">
                     <span onclick="return $.addCompare('{/shop/url}', {@id}, this)">
                        <xsl:if test="/shop/comparing/shop_item[@id = $shop_item_id]/node()">
                           <xsl:attribute name="class">compare-current</xsl:attribute>
                        </xsl:if>
                        <i class="fa fa-bar-chart"></i>
                     </span>
                  </div>
               </div>
            </div>
            
            <div class="product-content">
               <div class="product-marking">
                  <xsl:choose>
                     <xsl:when test="marking != ''"><xsl:value-of select="marking"/></xsl:when>
                     <xsl:otherwise>&#160;</xsl:otherwise>
                  </xsl:choose>
               </div>
               
               <div class="product-content-inner">
                  <div class="product-main-name">
                     <a href="{url}" title="{name}">
                        <xsl:value-of select="name"/>
                     </a>
                  </div>
                  
                  <div class="product-price text-center">
                     <span id="product-price-12-new" class="regular-price">
                        <span class="price">
                           <xsl:choose>
                              <xsl:when test="price &lt;= 0">Цена по запросу</xsl:when>
                              <xsl:otherwise>
                                 <xsl:apply-templates select="/shop/shop_currency/code">
                                    <xsl:with-param name="value" select="price" />
                                 </xsl:apply-templates>
                              </xsl:otherwise>
                           </xsl:choose>
                        </span>
                        <xsl:if test="discount != 0">
                           <span class="old-price">
                              <xsl:apply-templates select="/shop/shop_currency/code">
                                 <xsl:with-param name="value" select="price + discount" />
                              </xsl:apply-templates>
                           </span>
                        </xsl:if>
                     </span>
                  </div>
                  
                  <div class="product-rest">
                     <xsl:choose>
                     <xsl:when test="rest != 0"><xsl:value-of select="format-number(rest, '# ###', 'my')"/><xsl:text> </xsl:text>шт.</xsl:when>
                        <xsl:otherwise>Срок поставки по запросу</xsl:otherwise>
                     </xsl:choose>
                  </div>
                  
                  <div class="row">
                     <div class="col-xs-6 col-sm-7 padding-right-5">
                        <div class="product-quantity">
                           Кол-во
                           <div class="quantity">
                              <input id="quantity-{@id}" class="item-quantity" type="number" value="1" name="quantity" />
                              <span class="qty-wrapper">
                                 <span class="qty-inner">
                                    <span class="qty-up" data-src="#quantity-{@id}" title="+">
                                       <i class="fa fa-plus"></i>
                                    </span>
                                    <span class="qty-down" data-src="#quantity-{@id}" title="-">
                                       <i class="fa fa-minus"></i>
                                    </span>
                                 </span>
                              </span>
                           </div>
                        </div>
                     </div>
                     <div class="col-xs-6 col-sm-5 padding-left-5 text-right">
                        <div class="shop-item-add-to-cart">
                        <a class="shop-item-add-to-cart-link" href="#" onclick="return $.bootstrapAddIntoCart('{/shop/url}cart/', {@id}, $('#quantity-{@id}').val())" title="Добавить в корзину"><i class="fa fa-shopping-basket "></i></a>
                        </div>
                        <div class="shop-item-fast-order">
                        <a class="shop-item-fast-order-link" href="#" onclick="return $.oneStepCheckout('{/shop/url}cart/', {@id}, $('#quantity-{@id}').val())" title="Быстрый заказ" data-toggle="modal" data-target="#oneStepCheckout{@id}"><i class="fa fa-shopping-cart"></i></a>
                        </div>
                     </div>
                     
                     
                     <!-- <xsl:if test="count(shop_bonuses/shop_bonus)">
                        <div class="product-bonuses">
                           +<xsl:value-of select="shop_bonuses/total" /> бонусов
                        </div>
                     </xsl:if>
                     
                     <div class="product-action-buttons">
                        
                     </div>-->
                  </div>
               </div>
            </div>
         </div>
      </div>
   </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">
      <li><span class="ctrl">← Ctrl</span></li>
      </xsl:if>
      
      <xsl:if test="$i = ($page + $post_count_page + 1) and $n != ($page+1)">
      <li><span class="ctrl">Ctrl →</span></li>
      </xsl:if>-->
      <xsl:if test="$i = $start_page and $page != 0">
         <li>
         <span aria-hidden="true"><i class="fa fa-angle-double-left"></i></span>
         </li>
      </xsl:if>
      
      <xsl:if test="$i = ($page + $post_count_page + 1) and $n != ($page+1)">
         <li>
         <span aria-hidden="true"><i class="fa fa-angle-double-right"></i></span>
         </li>
      </xsl:if>
      
      <!-- Передаем фильтр -->
      <xsl:variable name="filter">
         <xsl:if test="search_text_urlencoded != ''">?text=<xsl:value-of select="search_text_urlencoded"/></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:value-of select="/shop/group_link"/>
            <!--<xsl:text>/searcher/</xsl:text>-->
         </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">
         <li><a href="{$group_link}{$tag_path}{$shop_producer_path}{$filter}" class="page_link" style="text-decoration: none;">←</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}" class="page_link">
                     <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}page-{$n}/{$tag_path}{$shop_producer_path}{$filter}" class="page_link" style="text-decoration: none;">→</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">page-<xsl:value-of select="$i"/>/</xsl:if>
            </xsl:variable>
         <!--<li><a href="{$group_link}{$prev_number_link}{$tag_path}{$shop_producer_path}{$filter}" id="id_prev"></a></li>-->
         </xsl:if>
         
         <!-- Ссылка на следующую страницу для Ctrl + вправо -->
         <xsl:if test="($n - 1) &gt; $page and $i = $page">
         <!--<li><a href="{$group_link}page-{$page+2}/{$tag_path}{$shop_producer_path}{$filter}" id="id_next"></a></li>-->
         </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_currency/code">
      <xsl:param name="value" />
      <xsl:variable name="spaced" select="format-number($value, '# ###', 'my')" />
      <xsl:choose>
         <xsl:when test=". = 'USD'">$<xsl:value-of select="$spaced"/></xsl:when>
         <xsl:when test=". = 'EUR'">€<xsl:value-of select="$spaced"/></xsl:when>
         <xsl:when test=". = 'GBP'">£<xsl:value-of select="$spaced"/></xsl:when>
      <xsl:when test=". = 'RUB'"><xsl:value-of select="$spaced"/><i class="fa fa-ruble"></i></xsl:when>
         <xsl:when test=". = 'AUD'">AU$<xsl:value-of select="$spaced"/></xsl:when>
         <xsl:when test=". = 'CNY'"><xsl:value-of select="$spaced"/>元</xsl:when>
         <xsl:when test=". = 'JPY'"><xsl:value-of select="$spaced"/>¥</xsl:when>
         <xsl:when test=". = 'KRW'"><xsl:value-of select="$spaced"/>₩</xsl:when>
         <xsl:when test=". = 'PHP'"><xsl:value-of select="$spaced"/>₱</xsl:when>
         <xsl:when test=". = 'THB'"><xsl:value-of select="$spaced"/>฿</xsl:when>
         <xsl:when test=". = 'BRL'">R$<xsl:value-of select="$spaced"/></xsl:when>
      <xsl:when test=". = 'INR'"><xsl:value-of select="$spaced"/><i class="fa fa-inr"></i></xsl:when>
      <xsl:when test=". = 'TRY'"><xsl:value-of select="$spaced"/><i class="fa fa-try"></i></xsl:when>
      <xsl:when test=". = 'ILS'"><xsl:value-of select="$spaced"/><i class="fa fa-ils"></i></xsl:when>
         <xsl:otherwise><xsl:value-of select="$spaced"/> <xsl:value-of select="." /></xsl:otherwise>
      </xsl:choose>
   </xsl:template>
   
</xsl:stylesheet>

ПрофильЦитировать выделенное20.01.2020 08:45:29 • Сообщений: 1
Re: Доработка стандартного шаблона поиска
#
Seri
У вас не штатный поиск. Условие поиска лежит в ТДС. А в xsl отображение результата.  
E-mail: info@syrbek.ru / skype: activexm / syrbek.ru / Поддержка сайтов / г. Москва

ПрофильЦитировать выделенное20.01.2020 10:56:25 • Сообщений: 718
Авторизация