Вывод товаров на главной странице в два столбика

#
Вывод товаров на главной странице в два столбика
Добрый день, перерыл форум, пытался сделать по аналогии с группами, но безуспешно....помогите: хочу сделать вывод товаров на главной странице в два столбика.
Вот мой шаблон:
<?xml version="1.0" encoding="windows-1251"?>
<!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="Windows-1251" 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">
      
      <!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
      <xsl:variable name="parent_group_id" select="@current_group_id"/>
      
      <!-- Если в находимся корне - выводим название магазина -->
      <!--<h1><xsl:value-of disable-output-escaping="yes" select="name" /></h1>-->
      
      <xsl:variable name="count">1</xsl:variable>
      
      <form method="get" action="./">
         <!-- Выводим товары магазина -->
         <xsl:if test="count(item) &gt; 0">
            <table cellspacing="2" cellpadding="2" border="0" width="100%" class="shop_table">
               <tr><td>
                     
                     <xsl:apply-templates select="item"/>
            </td></tr></table>
         </xsl:if>
      </form>
   </xsl:template>
   
   <!-- Шаблон для списка товаров для сравнения -->
   <xsl:template match="compare_items/compare_item">
      <xsl:variable name="var_compare_id" select="."/>
      <tr>
         <td>
            <a href="{/shop/path}{compare_item_fullpath}{compare_item_path}">
               <xsl:value-of disable-output-escaping="yes" select="compare_item_name"/>
            </a>
         </td>
         <td>
            <input type="checkbox" name="del_compare_id_{compare_item_id}" id="id_del_compare_id_{compare_item_id}"/>
            <label for="id_del_compare_id_{compare_item_id}">Да</label>
         </td>
      </tr>
   </xsl:template>
   
   <!-- Шаблон для фильтра производителей -->
   <xsl:template match="producerslist/producer">
      <option value="{@id}">
         <xsl:if test="@id = /shop/producer_id">
            <xsl:attribute name="selected">
            </xsl:attribute>
         </xsl:if>
         <xsl:value-of disable-output-escaping="yes" select="name"/>
      </option>
   </xsl:template>
   
   <!-- Шаблон для фильтра продавцов -->
   <xsl:template match="sallers/saller">
      <option value="{@id}">
         <xsl:if test="@id = /shop/saller_id">
            <xsl:attribute name="selected">
            </xsl:attribute>
         </xsl:if>
         <xsl:value-of select="sallers_name"/>
      </option>
   </xsl:template>
   
   <!-- Шаблон для фильра по дополнительным свойствам -->
   <xsl:template match="properties_for_group/property">
      <td>
         <xsl:value-of disable-output-escaping="yes" select="property_name"/>&#xA0;
         <xsl:if test="property_show_kind = 1">
            <!-- Отображаем поле ввода -->
            <xsl:variable name="nodename">property_id_<xsl:value-of select="@id"/></xsl:variable>
            <br/>
            <input type="text" name="property_id_{@id}">
               <xsl:if test="/shop/*[name()=$nodename] != ''">
                  <xsl:attribute name="value">
                     <xsl:value-of disable-output-escaping="yes" select="/shop/*[name()=$nodename]"/>
                  </xsl:attribute>
               </xsl:if>
            </input>
         </xsl:if>
         <xsl:if test="property_show_kind = 2">
            <!-- Отображаем список -->
            <br/>
            <select name="property_id_{@id}">
               <option value="0">...</option>-->
               <xsl:apply-templates select="list_items/list_item"/>
            </select>
         </xsl:if>
         <xsl:if test="property_show_kind = 3">
            <!-- Отображаем переключатели -->
            <br/>
            <input type="radio" name="property_id_{@id}" value="0" id="id_prop_radio_{@id}_0"></input>
            <label for="id_prop_radio_{@id}_0">Любой вариант</label>
            <xsl:apply-templates select="list_items/list_item"/>
         </xsl:if>
         <xsl:if test=" property_show_kind = 4">
            <!-- Отображаем флажки -->
            <xsl:apply-templates select="list_items/list_item"/>
         </xsl:if>
      </td>
      <xsl:if test="position() mod 6 = 0">
         <xsl:text disable-output-escaping="yes">
            &lt;/tr&gt;
            &lt;tr valign="top"&gt;
         </xsl:text>
      </xsl:if>
   </xsl:template>
   
   <xsl:template match="list_items/list_item">
      <xsl:if test="../../property_show_kind = 2">
         <!-- Отображаем список -->
         <xsl:variable name="nodename">property_id_<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="list_item_value"/>
         </option>
      </xsl:if>
      <xsl:if test="../../property_show_kind = 3">
         <!-- Отображаем переключатели -->
         <xsl:variable name="nodename">property_id_<xsl:value-of select="../../@id"/></xsl:variable>
         <br/>
         <input type="radio" name="property_id_{../../@id}" value="{@id}" id="id_property_id_{../../@id}_{@id}">
            <xsl:if test="/shop/*[name()=$nodename] = @id">
               <xsl:attribute name="checked">
               </xsl:attribute>
            </xsl:if>
            <label for="id_property_id_{../../@id}_{@id}">
               <xsl:value-of disable-output-escaping="yes" select="list_item_value"/>
            </label>
         </input>
      </xsl:if>
      <xsl:if test="../../property_show_kind = 4">
         <!-- Отображаем флажки -->
         <xsl:variable name="nodename">property_id_<xsl:value-of select="../../@id"/>_item_id_<xsl:value-of select="@id"/></xsl:variable>
         <br/>
         <input type="checkbox" name="property_id_{../../@id}_item_id_{@id}" id="id_property_id_{../../@id}_{@id}">
            <xsl:if test="/shop/*[name()=$nodename] = @id">
               <xsl:attribute name="checked">
               </xsl:attribute>
            </xsl:if>
            <label for="id_property_id_{../../@id}_{@id}">
               <xsl:value-of disable-output-escaping="yes" select="list_item_value"/>
            </label>
         </input>
      </xsl:if>
   </xsl:template>
   
   <!-- Шаблон для групп товара -->
   <xsl:template match="group">
      
      <xsl:param name="style_font">catalog_l0</xsl:param>
      <xsl:param name="style_font_sel">catalog_l0_selected</xsl:param>
      
      <tr>
         <td>
            
            <xsl:variable name="current_group_id" select="/shop/ТекущаяГруппа"/>
            
            <xsl:choose>
               <xsl:when test="$current_group_id = @id or count(.//group[@id=$current_group_id])=1">
                  <div class="{$style_font_sel}">
                     <b>
                        <a href="{/shop/path}{fullpath}">
                           <xsl:value-of disable-output-escaping="yes" select="name"/>
                        </a>
                     </b>
                  </div>
                  <table style="margin-left: 20px; margin-top: 0px; margin-bottom: 0px; padding-bottom: 0px" border="0">
                     <xsl:apply-templates select="group">
                        <xsl:with-param name="style_font">catalog_l1</xsl:with-param>
                        <xsl:with-param name="style_font_sel">catalog_l1</xsl:with-param>
                     </xsl:apply-templates>
                  </table>
               </xsl:when>
               <xsl:otherwise>
                  <div class="{$style_font}">
                     <a href="{/shop/path}{fullpath}">
                        <xsl:value-of disable-output-escaping="yes" select="name"/>
                     </a>
                  </div>
               </xsl:otherwise>
            </xsl:choose>
         </td>
      </tr>
   </xsl:template>
   

   <!-- Шаблон для товара -->
   <xsl:template match="item">
      
      <!-- Определяем цвет фона -->
      <xsl:variable name="background_color">
         <xsl:choose>
            <xsl:when test="(position() + 1) mod 2 &gt; 0">#f7f7f7</xsl:when>
            <xsl:otherwise>#ffffff</xsl:otherwise>
         </xsl:choose>
      </xsl:variable>
      
      <table width="300" cellspacing="0" cellpadding="0" border="0" style="background:url(/bel/itembg.gif) repeat-x; height:153px; padding:2px; margin:2px;" ><tr><td>
               <!-- Изображения для товара, если есть -->
               <xsl:if test="small_image!=''">
                  <a href="{/shop/path}{fullpath}{path}/" style="padding:0px;">
                     <img src="{small_image}" align="top" height="147" width="137"/>
                  </a>
            </xsl:if></td><td width="100%">
               <table height="100%" width="100%" border="0"><tr><td>
                        <!-- Название товара -->
                        <p class="name_product"><b>
                              <a href="{/shop/path}{fullpath}{path}/">
                                 <xsl:value-of disable-output-escaping="yes" select="name"/>
                              </a>
                        </b></p>
                  </td></tr>
                  <tr><td height="100%">
                        <p class="opis_product">
                           <!-- Описание товара -->
                           <xsl:value-of disable-output-escaping="yes" select="description"/>
                        </p>
                  </td></tr>
                  <tr><td>
                        <!-- Цена товара товара -->
                        <p class="price">
                           Цена:&#xA0;<xsl:value-of disable-output-escaping="yes" select="price"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="currency"/>&#xA0;               
                        </p>
               </td></tr></table>

      </td></tr></table>
      
      
   </xsl:template>
   
   
   
   <!-- Шаблон для модификаций -->
   <xsl:template match="modifications/item">
      <tr>
         <td>
            <!-- Название модификации -->
            <a href="{/shop/path}{fullpath}{path}/">
               <xsl:value-of disable-output-escaping="yes" select="name"/>
            </a>
         </td>
         <td>
            <!-- Цена модификации -->
            <xsl:value-of disable-output-escaping="yes" select="price"/>&#xA0;
            <!-- Валюта -->
            <xsl:value-of disable-output-escaping="yes" select="currency"/>
         </td>
      </tr>
   </xsl:template>
   
   <!-- Шаблон для скидки -->
   <xsl:template match="discount">
      <br/>
      <xsl:value-of disable-output-escaping="yes" select="name"/>&#xA0;
      <xsl:value-of disable-output-escaping="yes" select="value"/>%</xsl:template>
   
   <!-- ======================================================== -->
   <!-- Шаблон выводит рекурсивно ссылки на группы инф. элемента -->
   <!-- ======================================================== -->
   
   <xsl:template match="group" mode="goup_path">
      <xsl:param name="parent_id" select="@parent"/>
      
      <!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
      <xsl:param name="parent_group_id" select="/shop/@current_group_id"/>
      
      <xsl:apply-templates select="//group[@id=$parent_id]" mode="goup_path"/>
      
      <xsl:if test="@parent=0">
         <a href="{/shop/path}">
            <xsl:value-of disable-output-escaping="yes" select="/shop/name"/>
         </a>
      </xsl:if>
      
      <img src="/images/arrow_path.gif" class="arrow_path"/>
      
      <!-- ============================================================================================== -->
      <!-- Если ID группы, для которой выводим список элементов, равен ID текущей группы - выводим жирным -->
      <!-- ============================================================================================== -->
      <xsl:if test="$parent_group_id=@id">
         <a href="{/shop/path}{fullpath}">
            <b>
               <xsl:value-of disable-output-escaping="yes" select="name"/>
            </b>
         </a>
      </xsl:if>
      
      <!-- ============================ -->
      <!-- Иначе выводим обычную ссылку -->
      <!-- ============================ -->
      <xsl:if test="$parent_group_id!=@id">
         <a href="{/shop/path}{fullpath}">
            <xsl:value-of disable-output-escaping="yes" select="name"/>
         </a>
      </xsl:if>
   </xsl:template>
</xsl:stylesheet>
Студия дизайна Advanced Systems
Модератор
#
Re: Вывод товаров на главной странице в два столбика
dezigner,
1. код вставлять нужно BB-тегом code (синяя кнопка <>
2. выделите тот код, которым Вы пытаетесь сделать в два столбца.
#
Re: Вывод товаров на главной странице в два столбика

<!-- Шаблон для товара -->
   <xsl:template match="item">
      
      <!-- Определяем цвет фона -->
      <xsl:variable name="background_color">
         <xsl:choose>
            <xsl:when test="(position() + 1) mod 2 &gt; 0">#f7f7f7</xsl:when>
            <xsl:otherwise>#ffffff</xsl:otherwise>
         </xsl:choose>
      </xsl:variable>
      
      <table width="300" cellspacing="0" cellpadding="0" border="0" style="background:url(/bel/itembg.gif) repeat-x; height:153px; padding:2px; margin:2px;" ><tr><td>
               <!-- Изображения для товара, если есть -->
               <xsl:if test="small_image!=''">
                  <a href="{/shop/path}{fullpath}{path}/" style="padding:0px;">
                     <img src="{small_image}" align="top" height="147" width="137"/>
                  </a>
            </xsl:if></td><td width="100%">
               <table height="100%" width="100%" border="0"><tr><td>
                        <!-- Название товара -->
                        <p class="name_product"><b>
                              <a href="{/shop/path}{fullpath}{path}/">
                                 <xsl:value-of disable-output-escaping="yes" select="name"/>
                              </a>
                        </b></p>
                  </td></tr>
                  <tr><td height="100%">
                        <p class="opis_product">
                           <!-- Описание товара -->
                           <xsl:value-of disable-output-escaping="yes" select="description"/>
                        </p>
                  </td></tr>
                  <tr><td>
                        <!-- Цена товара товара -->
                        <p class="price">
                           Цена:&#xA0;<xsl:value-of disable-output-escaping="yes" select="price"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="currency"/>&#xA0;
                        </p>
               </td></tr></table>
               
      </td></tr></table>
      <xsl:if test="position()= round(count(//item[@parent = $parent_id]) div 2)">
         <xsl:text disable-output-escaping="yes">
            &lt;/td&gt;
            &lt;td valign="top" width="50%"&gt;
         </xsl:text>
      </xsl:if>

      
   </xsl:template>



вот так пытался, скопировал условие if и изменил group на item
Студия дизайна Advanced Systems
#
Re: Вывод товаров на главной странице в два столбика
кстати: нашел в МагазинКаталогТоваровНаГлавной вот такой закоментированный код:

<!-- На строку - не более 3-х пунктов, если уже 3 выведено - начинаем новую строку -->
      <xsl:if test="position() mod 3 = 0">
         <xsl:text disable-output-escaping="yes">
            &lt;/tr&gt;
            &lt;tr&gt;
         </xsl:text>
      </xsl:if>


раскоментировал его но тем не менее список так и выводится в один столбик, почему?
Студия дизайна Advanced Systems
#
Re: Вывод товаров на главной странице в два столбика
dezigner,
а тут не пробовали смотреть:
http://www.hostcms.ru/forums/22/2169/
#
Re: Re: Вывод товаров на главной странице в два столбика
dezigner писал(а):
раскоментировал его но тем не менее список так и выводится в один столбик, почему?

а если написать вместо
<xsl:if test="position() mod 3 = 0">
следующее:
<xsl:if test="position() = 3">
Авторизация