Работа с дополнительными свойствами в HostCMS v. 6

Re: Работа с дополнительными свойствами в HostCMS v. 6
Установила халяву, создала сайт с шаблоном интернет магазин. В интернет магазине в группе свойств сделала активными доп.свойсва - фото1, фото2 При редактированиии товара добавила фотографии. Но почему-то доп.фото не выводятся. XSL-шаблон МагазинТоварСайт24 не меняла.  

Цитата:
<?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"/>

   <!-- МагазинТовар -->
   <xslecimal-format name="my" decimal-separator="," grouping-separator=" "/>

   <xsl:template match="/shop">
      <xsl:apply-templates select="shop_item"/>
   </xsl:template>

   <xsl:template match="shop_item">
      <h1 hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_item"><xsl:value-of disable-output-escaping="yes" select="name"/></h1>

      <!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
      <xsl:variable name="parent_group_id" select="/shop/shop_group"/>

      <div class="indent">
         <!-- Получаем ID родительской группы и записываем в переменную $group -->
         <xsl:variable name="group" select="/shop/group"/>
         <div class="path">
            <xsl:if test="$group = 0">
               <a href="{/shop/url}" hostcms:id="{/shop/@id}" hostcms:field="name" hostcms:entity="shop">
                  <xsl:value-of disable-output-escaping="yes" select="/shop/name"/>
               </a>
            </xsl:if>

            <!-- Путь к группе -->
            <xsl:apply-templates select="/shop//shop_group[@id=$group]" mode="breadCrumbs"/>

            <!-- Если модификация, выводим в пути родительский товар -->
            <xsl:if test="shop_item/node()">
               <span class="url_arrow"><xsl:text> → </xsl:text></span>
               <a href="{shop_item/url}">
                  <xsl:value-of disable-output-escaping="yes" select="shop_item/name"/>
               </a>
            </xsl:if>

            <span class="url_arrow"><xsl:text> → </xsl:text></span>

            <b><a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_item"><xsl:value-of disable-output-escaping="yes" select="name"/></a></b>
         </div>

         <!-- Средняя оценка товара -->
         <xsl:if test="comments/average_grade/node()">
            <div style="float: left; margin-bottom:10px">
               <xsl:call-template name="show_average_grade">
                  <xsl:with-param name="grade" select="comments/average_grade"/>
                  <xsl:with-param name="const_grade" select="5"/>
               </xsl:call-template>
            </div>
            <div style="clear: both"></div>
         </xsl:if>

         <!-- Выводим сообщение -->
         <xsl:if test="/shop/message/node()">
            <xsl:value-of disable-output-escaping="yes" select="/shop/message"/>
         </xsl:if>

         <div id="gallery">
            <!-- Изображение для товара, если есть -->
            <xsl:if test="image_small != ''">
               <div>
                  <a href="{dir}{image_large}" target="_blank">
                     <img src="{dir}{image_small}" class="goods_img" />
                  </a>
               </div>
            </xsl:if>

            <!-- Цена товара -->
            <p class="price">
               <xsl:choose>
                  <xsl:when test="price != 0">
                     <xsl:value-of select="format-number(price, '### ##0,00', 'my'"/>&#xA0;<xsl:value-of select="currency" disable-output-escaping="yes"/>
                  </xsl:when>
                  <xsl:otherwise>договорная</xsl:otherwise>
               </xsl:choose>

               <!-- Если цена со скидкой - выводим ее -->
               <xsl:if test="discount != 0">
                  <xsl:variable name="price_tax" select="price_tax"/>
                  <div class="price_discount">
                     <xsl:value-of select="format-number(price + discount, '### ##0,00', 'my'"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="currency"/>
                  </div>
               </xsl:if>
            </p>

            <!-- Ссылку на добавление в корзины выводим, если:
            type != 1 - простой тип товара или делимый (0 - простой, 2 - делимый)
            type = 1 - электронный товар, при этом остаток на складе больше 0 или -1,
            что означает неограниченное количество -->
            <xsl:if test="type != 1 or (type = 1 and (digitals > 0 or digitals = -1))">
               <p>
                  <input type="text" size="3" value="1" id="count_{@id}" style="height: 17px;"/>
                  <img src="/images/map_intocart.gif" width="12" height="21" border="0" usemap="#mapInToCart{@id}" style="margin: 0 0 -6px 1px;"/>
                  <a href="{/shop/url}cart/?add={@id}" onclick="return $.addIntoCart('{/shop/url}cart/', {@id}, document.getElementById('count_{@id}'.value)">
                     <img alt="В корзину" title="В корзину" src="/hostcmsfiles/images/cart.gif" style="margin: 0px 0px -4px 10px" />
                  </a>
                  <map name="mapInToCart{@id}">
                     <area shape="rect" coords="0,0,12,10" onclick="set_count_mod('count_{@id}', 1);" nohref="nohref" />
                     <area shape="rect" coords="0,11,12,21" onclick="set_count_mod('count_{@id}', -1);" nohref="nohref" />
                  </map>
               </p>
            </xsl:if>

            <p class="goods_info" style="margin-left: 90px;">
               <xsl:if test="marking != ''">
                  Артикул: <b><xsl:value-of disable-output-escaping="yes" select="marking"/></b>
                  <br/>
               </xsl:if>
               Код товара: <b><xsl:value-of disable-output-escaping="yes" select="@id"/></b>
               <xsl:if test="property_value[tag_name='available_sizes']/value != ''">
                  <br />
                  Доступные размеры:   <b><xsl:value-of name="price" select="property_value[tag_name='available_sizes']/value"/></b>
               </xsl:if>

               <xsl:if test="shop_producer/name != ''">
                  <br />Производитель: <b><xsl:value-of disable-output-escaping="yes" select="shop_producer/name"/></b>
               </xsl:if>

               <!-- Если указан вес товара -->
               <xsl:if test="weight != 0">
                  <br />Вес товара: <xsl:value-of select="weight"/>&#xA0;<xsl:value-of select="/shop/shop_measure/name"/>
               </xsl:if>

               <!-- Показываем количество на складе, если больше нуля -->
               <xsl:if test="rest &gt; 0">
                  <p>В наличии: <xsl:value-of disable-output-escaping="yes" select="rest"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="mesure"/></p>
               </xsl:if>
            </p>
            <!-- Описание товара -->
            <!--<xsl:value-of disable-output-escaping="yes" select="description" />-->

            <!-- Если электронный товар, выведим доступное количество -->
            <xsl:if test="type = 1">
               <p>
                  <strong>
                     <xsl:choose>
                        <xsl:when test="digitals = 0">
                           Электронный товар закончился.
                        </xsl:when>
                        <xsl:when test="digitals = -1">
                           Электронный товар доступен для заказа.
                        </xsl:when>
                        <xsl:otherwise>
                        На складе осталось: <xsl:value-of select="digitals" /><xsl:text> </xsl:text><xsl:value-of select="mesure" />
                        </xsl:otherwise>
                     </xsl:choose>
                  </strong>
               </p>
            </xsl:if>

            <!-- Текст товара -->
            <xsl:if test="text != ''">
               <div hostcms:id="{@id}" hostcms:field="text" hostcms:entity="shop_item" hostcms:type="wysiwyg"><xsl:value-of disable-output-escaping="yes" select="text"/></div>
            </xsl:if>

            <!-- Дополнительные изображения товара -->
            <div>
               <xsl:apply-templates select="property[type = 1]" mode="images"/>
            </div>

            <div style="clear: both;"></div>

            <!--
            <xsl:if test="count(property) > 0">
               <h2>Атрибуты товара</h2>
               <xsl:if test="count(property[@dir_id = 0])">
                  <table border="0">
                     <xsl:apply-templates select="property[@dir_id = 0]"/>
                  </table>
               </xsl:if>
               <xsl:apply-templates select="/shop/properties_items_dir"/>
            </xsl:if>
            -->
         </div>

         <!-- Тэги для информационного элемента -->
         <xsl:if test="count(tag) &gt; 0">
            <p>
               <img src="/hostcmsfiles/images/tags.gif" align="left" style="margin: 0px 5px -2px 0px"/>
               <xsl:apply-templates select="tag"/>
            </p>
         </xsl:if>

         <!-- Модификации -->
         <xsl:if test="count(modifications/shop_item) &gt; 0">
            <b>Модификации:</b>
            <table cellspacing="3" cellpadding="3" style="margin-left: -6px;">
               <tr>
                  <td style="border-bottom: 1px solid #dadada;">Название</td>
                  <td style="border-bottom: 1px solid #dadada;">Цена</td>
               </tr>
               <xsl:apply-templates select="modifications/shop_item"/>
            </table>
         </xsl:if>

         <xsl:if test="count(tying/shop_item) &gt; 0">
            <p>
               <b>Сопутствующие товары:</b>
            </p>
            <!-- Отображаем сопутствующие товары -->
            <xsl:apply-templates select="tying/shop_item"/>
            <div style="clear: both;"></div>
         </xsl:if>

         <!-- Если указано отображать комментарии -->
         <xsl:if test="/shop/show_comments/node() and /shop/show_comments = 1">
            <!-- Отображение комментариев  -->
            <xsl:if test="count(comment) &gt; 0">
               <p class="title">
               <a name="comments"></a>Отзывы о товаре</p>
               <xsl:apply-templates select="comment"/>
            </xsl:if>
         </xsl:if>

         <!-- Если разрешено отображать формы добавления комментария
         1 - Только авторизированным
         2 - Всем
         -->
         <xsl:if test="/shop/show_add_comments/node() and ((/shop/show_add_comments = 1 and /shop/siteuser_id &gt; 0)  or /shop/show_add_comments = 2)">

            <div id="ShowAddComment"><a href="javascript:void(0)" onclick="$('.comment_reply'.hide('slow';$('#AddComment'.toggle('slow'">Добавить комментарий</a></div>

            <div id="AddComment" style="display: none">
               <xsl:call-template name="AddCommentForm"></xsl:call-template>
            </div>
         </xsl:if>
      </div>
   </xsl:template>

   <!-- Шаблон вывода добавления комментария -->
   <xsl:template name="AddCommentForm">
      <xsl:param name="id" select="0"/>

      <!-- Заполняем форму -->
      <xsl:variable name="subject">
         <xsl:if test="/shop/comment/parent_id/node() and /shop/comment/parent_id/node() and /shop/comment/parent_id= $id">
            <xsl:value-of select="/shop/comment/subject"/>
         </xsl:if>
      </xsl:variable>
      <xsl:variable name="email">
         <xsl:if test="/shop/comment/email/node() and /shop/comment/parent_id/node() and /shop/comment/parent_id= $id">
            <xsl:value-of select="/shop/comment/email"/>
         </xsl:if>
      </xsl:variable>
      <xsl:variable name="phone">
         <xsl:if test="/shop/comment/parent_id/node() and /shop/comment/parent_id/node() and /shop/comment/parent_id= $id">
            <xsl:value-of select="/shop/form_user_phone"/>
         </xsl:if>
      </xsl:variable>
      <xsl:variable name="text">
         <xsl:if test="/shop/comment/text/node() and /shop/comment/parent_id/node() and /shop/comment/parent_id= $id">
            <xsl:value-of select="/shop/comment/text"/>
         </xsl:if>
      </xsl:variable>
      <xsl:variable name="name">
         <xsl:if test="/shop/comment/author/node() and /shop/comment/parent_id/node() and /shop/comment/parent_id= $id">
            <xsl:value-of select="/shop/comment/author"/>
         </xsl:if>
      </xsl:variable>

      <div class="comment">
         <!--Отображение формы добавления комментария-->
         <form action="{/shop/shop_item/url}" name="comment_form_0{$id}" method="post">
            <!-- Авторизированным не показываем -->
            <xsl:if test="/shop/siteuser_id = 0">

               <div class="row">
                  <div class="caption">Имя</div>
                  <div class="field">
                     <input type="text" size="30" name="author" value="{$name}"/>
                  </div>
               </div>

               <div class="row">
                  <div class="caption">E-mail</div>
                  <div class="field">
                     <input id="email{$id}" type="text" size="30" name="email" value="{$email}" />
                     <div id="error_email{$id}"></div>
                  </div>
               </div>

               <div class="row">
                  <div class="caption">Телефон</div>
                  <div class="field">
                     <input type="text" size="30" name="comment_phone" value="{$phone}"/>
                  </div>
               </div>
            </xsl:if>

            <div class="row">
               <div class="caption">Тема</div>
               <div class="field">
                  <input type="text" size="30" name="subject" value="{$subject}"/>
               </div>
            </div>

            <div class="row">
               <div class="caption">Комментарий</div>
               <div class="field">
                  <textarea name="text" cols="30" rows="4" class="mceEditor"><xsl:value-of select="$text"/></textarea>
               </div>
            </div>

            <div class="row">
               <div class="caption">Оценка</div>
               <div class="field stars">
                  <select name="grade">
                     <option value="1">Poor</option>
                     <option value="2">Fair</option>
                     <option value="3">Average</option>
                     <option value="4">Good</option>
                     <option value="5">Excellent</option>
                  </select>
               </div>
            </div>

            <!-- Обработка CAPTCHA -->
            <xsl:if test="//captcha_id != 0 and /shop/siteuser_id = 0">
               <div class="row">
                  <div class="caption"></div>
                  <div class="field">
                     <img id="comment_{$id}" class="captcha" src="/captcha.php?id={//captcha_id}{$id}&amp;height=30&amp;width=100" title="Контрольное число" name="captcha"/>

                     <div class="captcha">
                        <img src="/images/site24/refresh.png" /> <span onclick="$('#comment_{$id}'.updateCaptcha('{//captcha_id}{$id}', 30); return false">Показать другое число</span>
                     </div>
                  </div>
               </div>

               <div class="row">
                  <div class="caption">
                     Контрольное число<sup><font color="red">*</font></sup>
                  </div>
                  <div class="field">
                     <input type="hidden" name="captcha_id" value="{//captcha_id}{$id}"/>
                     <input type="text" name="captcha" size="15"/>
                  </div>
               </div>
            </xsl:if>

            <xsl:if test="$id != 0">
               <input type="hidden" name="parent_id" value="{$id}"/>
            </xsl:if>

            <div class="row">
               <div class="caption"></div>
               <div class="field">
                  <input id="submit_email{$id}" type="submit" name="add_comment" value="Опубликовать" class="button" />
               </div>
            </div>
         </form>
      </div>
   </xsl:template>

   <!-- Вывод раздела для свойств товара -->
   <xsl:template match="properties_items_dir">

      <xsl:variable name="dir_id" select="@id"/>

      <xsl:if test="count(/shop/item/property[@dir_id = $dir_id])">
         <!-- Название группы свойств -->
      <p><b><xsl:value-of select="shop_properties_items_dir_name"/></b></p>

         <table border="0">
            <xsl:apply-templates select="/shop/item/property[@dir_id = $dir_id]"/>
         </table>
      </xsl:if>

      <xsl:if test="count(properties_items_dir) > 0">
         <blockquote>
            <xsl:apply-templates select="properties_items_dir"/>
         </blockquote>
      </xsl:if>
   </xsl:template>

   <!-- Вывод строки со значением свойства -->
   <xsl:template match="property">
<xsl:if test="value/node() and value != '' or file/node() and file != ''">
      
         <tr>
            <td style="padding: 5px" bgcolor="#eeeeee">
               <b><xsl:value-of select="name"/></b>
            </td>
            <td style="padding: 5px" bgcolor="#eeeeee">

               <xsl:choose>
                  <xsl:when test="type = 1">
                     <a href="{file_url}">Скачать файл</a>
                  </xsl:when>
                  <xsl:when test="type = 7">
                     <xsl:choose>
                        <xsl:when test="value = 1">
                           <input type="checkbox" checked="" disabled="" />
                        </xsl:when>
                        <xsl:otherwise>
                           <input type="checkbox" disabled="" />
                        </xsl:otherwise>
                     </xsl:choose>
                  </xsl:when>
                  <xsl:otherwise>
                     <xsl:value-of disable-output-escaping="yes" select="value"/>
                  </xsl:otherwise>
               </xsl:choose>
            </td>
         </tr>
      </xsl:if>
   </xsl:template>

   <xsl:template match="property" mode="images">
      <xsl:if test="file_url/node() and file_url != ''">
         <a href="{file_url}"><img src="{image_small/file_url}" class="goods_img" /></a>
      </xsl:if>
   </xsl:template>

   <!-- /// Метки для информационного элемента /// -->
   <xsl:template match="tag">
      <a href="{/shop/url}tag/{urlencode}/" class="tag">
         <xsl:value-of select="name"/>
      </a>
   <xsl:if test="position() != last()"><xsl:text>, </xsl:text></xsl:if>
   </xsl:template>

   <!-- Шаблон для модификаций -->
   <xsl:template match="modifications/shop_item">
      <tr>
         <td>
            <!-- Название модификации -->
            <a href="{url}">
               <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 name="show_average_grade">
      <xsl:param name="grade" select="0"/>
      <xsl:param name="const_grade" select="0"/>

      <!-- Чтобы избежать зацикливания -->
      <xsl:variable name="current_grade" select="$grade * 1"/>

      <xsl:choose>
         <!-- Если число целое -->
         <xsl:when test="floor($current_grade) = $current_grade and not($const_grade &gt; ceiling($current_grade))">

            <xsl:if test="$current_grade - 1 &gt; 0">
               <xsl:call-template name="show_average_grade">
                  <xsl:with-param name="grade" select="$current_grade - 1"/>
                  <xsl:with-param name="const_grade" select="$const_grade - 1"/>
               </xsl:call-template>
            </xsl:if>

            <xsl:if test="$current_grade != 0">
               <img src="/hostcmsfiles/images/stars_single.gif"/>
            </xsl:if>
         </xsl:when>
         <xsl:when test="$current_grade != 0 and not($const_grade &gt; ceiling($current_grade))">

            <xsl:if test="$current_grade - 0.5 &gt; 0">
               <xsl:call-template name="show_average_grade">
                  <xsl:with-param name="grade" select="$current_grade - 0.5"/>
                  <xsl:with-param name="const_grade" select="$const_grade - 1"/>
               </xsl:call-template>
            </xsl:if>

            <img src="/hostcmsfiles/images/stars_half.gif"/>
         </xsl:when>

         <xsl:otherwise>
            <!-- Выводим серые звездочки, пока текущая позиция не дойдет то значения, увеличенного до целого -->
            <xsl:call-template name="show_average_grade">
               <xsl:with-param name="grade" select="$current_grade"/>
               <xsl:with-param name="const_grade" select="$const_grade - 1"/>
            </xsl:call-template>
            <img src="/hostcmsfiles/images/stars_gray.gif"/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>

   <!-- Шаблон для вывода звездочек (оценки) -->
   <xsl:template name="for">
      <xsl:param name="i" select="0"/>
      <xsl:param name="n"/>

      <input type="radio" name="shop_grade" value="{$i}" id="id_shop_grade_{$i}">
         <xsl:if test="/shop/shop_grade = $i">
            <xsl:attribute name="checked">
            </xsl:attribute>
         </xsl:if>
      </input>&#xA0;
      <label for="id_shop_grade_{$i}">
         <xsl:call-template name="show_average_grade">
            <xsl:with-param name="grade" select="$i"/>
            <xsl:with-param name="const_grade" select="5"/>
         </xsl:call-template>
      </label>
      <br/>
      <xsl:if test="$n &gt; $i and $n &gt; 1">
         <xsl:call-template name="for">
            <xsl:with-param name="i" select="$i + 1"/>
            <xsl:with-param name="n" select="$n"/>
         </xsl:call-template>
      </xsl:if>
   </xsl:template>

   <!-- Отображение комментариев -->
   <xsl:template match="comment">
      <!-- Отображаем комментарий, если задан текст или тема комментария -->
      <xsl:if test="text != '' or subject != ''">
         <a name="comment{@id}"></a>
         <div class="comment" id="comment{@id}">
            <xsl:if test="subject != ''">
               <div class="subject" hostcms:id="{@id}" hostcms:field="subject" hostcms:entity="comment"><xsl:value-of select="subject"/></div>
            </xsl:if>

            <div hostcms:id="{@id}" hostcms:field="text" hostcms:entity="comment" hostcms:type="wysiwyg"><xsl:value-of select="text" disable-output-escaping="yes"/></div>

            <p class="tags">
               <!-- Оценка комментария -->
               <xsl:if test="grade != 0">
                  <span><xsl:call-template name="show_average_grade">
                     <xsl:with-param name="grade" select="grade"/>
                     <xsl:with-param name="const_grade" select="5"/>
                  </xsl:call-template></span>
               </xsl:if>

               <img src="/images/site24/user.png" />
               <xsl:choose>
               <!-- Комментарий добавил авторизированный пользователь -->
               <xsl:when test="count(siteuser) &gt; 0">
                  <span><a href="/users/info/{siteuser/login}/"><xsl:value-of select="siteuser/login"/></a></span>
               </xsl:when>
               <!-- Комментарй добавил неавторизированный пользователь -->
               <xsl:otherwise>
                  <span><xsl:value-of select="author" /></span>
               </xsl:otherwise>
               </xsl:choose>

               <img src="/images/site24/calendar.png" /> <span><xsl:value-of select="datetime"/></span>

               <xsl:if test="/shop/show_add_comments/node()
                  and ((/shop/show_add_comments = 1 and /shop/siteuser_id > 0)
                  or /shop/show_add_comments = 2)">
               <span class="red" onclick="$('.comment_reply'.hide('slow';$('#cr_{@id}'.toggle('slow'">ответить</span></xsl:if>

               <span class="red"><a href="{/shop/shop_item/url}#comment{@id}" title="Ссылка на комментарий">#</a></span>
            </p>
         </div>

         <!-- Отображаем только авторизированным пользователям -->
         <xsl:if test="/shop/show_add_comments/node() and ((/shop/show_add_comments = 1 and /shop/siteuser_id > 0) or /shop/show_add_comments = 2)">
            <div class="comment_reply" id="cr_{@id}">
               <xsl:call-template name="AddCommentForm">
                  <xsl:with-param name="id" select="@id"/>
               </xsl:call-template>
            </div>
         </xsl:if>

         <!-- Выбираем дочерние комментарии -->
         <xsl:if test="count(comment)">
            <div class="comment_sub">
               <xsl:apply-templates select="comment"/>
            </div>
         </xsl:if>
      </xsl:if>
   </xsl:template>

   <xsl:template match="tying/shop_item">

      <div style="clear: both">
         <p>
            <a href="{url}">
               <xsl:value-of select="name"/>
            </a>
         </p>

         <!-- Изображение для товара, если есть -->
         <xsl:if test="image_small != ''">
            <a href="{url}">
               <img src="{dir}{image_small}" align="left" style="border: 1px solid #000000; margin: 0px 5px 5px 0px"/>
            </a>
         </xsl:if>

         <p>
            <xsl:value-of disable-output-escaping="yes" select="description"/>
         </p>

         <!-- Цена товара -->
         <strong>
            <xsl:choose>
               <xsl:when test="price != 0">
                  <xsl:value-of disable-output-escaping="yes" select="price"/>&#xA0;
                  <!-- Валюта товара -->
                  <xsl:value-of disable-output-escaping="yes" select="currency"/>
               </xsl:when>
               <xsl:otherwise>договорная</xsl:otherwise>
            </xsl:choose>
         </strong>

         <!-- Если цена со скидкой - выводим ее -->
         <xsl:if test="discount != 0">
            <br/>
            <font color="gray">
               <strike>
                  <xsl:value-of disable-output-escaping="yes" select="price + discount"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="currency"/></strike>
            </font>
         </xsl:if>

         <!-- Если указан вес товара -->
         <xsl:if test="weight != 0">
            <br/>Вес товара: <xsl:value-of select="weight"/> <xsl:value-of select="/shop/shop_measure/name"/></xsl:if>

         <!-- Показываем скидки -->
         <xsl:if test="count(discount) &gt; 0">
            <xsl:apply-templates select="discount"/>
         </xsl:if>

         <!-- Показываем количество на складе, если больше нуля -->
         <xsl:if test="rest &gt; 0">
            <br/>В наличии: <xsl:value-of disable-output-escaping="yes" select="rest"/></xsl:if>

         <xsl:if test="shop_producer/name != ''">
            <br/>Производитель: <xsl:value-of disable-output-escaping="yes" select="shop_producer/name"/></xsl:if>
      </div>
   </xsl:template>

   <!-- Шаблон выводит хлебные крошки -->
   <xsl:template match="shop_group" mode="breadCrumbs">
      <xsl:variable name="parent_id" select="parent_id"/>

      <!-- Выбираем рекурсивно вышестоящую группу -->
      <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 class="url_arrow"><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:stylesheet>
Re: Re: Работа с дополнительными свойствами в HostCMS v. 6
Цитата:
Директорию брать от того объекта, значением св-ва которого он является

ясно, я вот копался, копался, но не понял, а как эту директорию узнать?
вот тут
Core_Page::instance()->object

нет ничего про директорию(
Модератор
Re: Работа с дополнительными свойствами в HostCMS v. 6
spuR,
например, у модели товара метод getItemPath(), далее у значения св-ва вызываете:
$oProperty_Value
      ->setHref($oShop_Item->getItemHref())
      ->setDir($oShop_Item->getItemPath());
Re: Работа с дополнительными свойствами в HostCMS v. 6
Есть проблема. Прошу прощения, если дублирую уже заданный вопрос...

В 5-й версии сортировка доп. св-в при выводе на страничке товара происходила по полю "сортировка". Т.е. работало с моей точки зрения логично. После перехода на 6-ю версию, доп. св-ва товара выводятся с сортировкой по айдишнику. Т.е. какое бы значение не было в теге <order></order> сортировка свойств от него не зависит.

Заранее спасибо.
Sincerely yours, mr. Den Golovastikov
Модератор
Re: Работа с дополнительными свойствами в HostCMS v. 6
hattab,
Порядок сортировки есть у свойств, в 6-й версии одно св-во может иметь много значений, сами значения хранятся в пяти разных таблицах, где никаких порядков сортировки не было и нет.
Для требуемой Вам реализации необходимо на XSL-шаблоне изменить порядок вывода: www.hostcms.ru/forums/2/8818/
Re: Работа с дополнительными свойствами в HostCMS v. 6
HostCMS, значения св-ств меня пока не интересуют. Интересует, можно ли через API достучаться до сортировки самих свойств, как это реализовано в товарах интернет-магазина через элементы массива $param['items_field_order'] и $param['items_order'], например. Допустим, все свойства определенного товара имеют 1 (одно) значение. Могу ли я в php коде динамической страницы вывода конкретного товара, указать поле, по которому нужно будет сортировать доп. св-ва. Название, либо ID, либо xml-тег, либо порядок сортировки. Или для того, чтобы изменить поле сортировки мне нужно каждый раз переписывать XSL-шаблон? Это для меня неудобно. Заранее спасибо.
Sincerely yours, mr. Den Golovastikov
Модератор
Re: Работа с дополнительными свойствами в HostCMS v. 6
hattab, сами св-ва сортируются так:
   /**
    * Default sorting for models
    * @var array
    */
   protected $_sorting = array(
      'properties.sorting' => 'ASC'
   );
но никак не по ID. Где именно (в контроллере показа чего-либо, еще где-то) Вы хотите менять направление сортировки свойств из Вашего сообщения не ясно.
Re: Работа с дополнительными свойствами в HostCMS v. 6
HostCMS, ясно, спасибо, ответ понятен.
Sincerely yours, mr. Den Golovastikov
Re: Работа с дополнительными свойствами в HostCMS v. 6
Задача: вывести в XML элементы структуры, имеющие хотя бы одно непустое св-во типа "Файл".

Код (выполняется в макете):
<?
$Structure_Controller_Show1 = new Structure_Controller_Show(
        Core_Entity::factory('Site', CURRENT_SITE)
    );

    $Structure_Controller_Show1
//->level(1)
->showProperties(TRUE)
        ->xsl(
            Core_Entity::factory('Xsl')->getByName('bbb_mid_mnu')
        );

// Объединение с нужной таблицей свойств
      $Structure_Controller_Show1
         ->structure()
         ->queryBuilder()
         ->leftJoin('structure_properties', 'structures.site_id', '=', 'structure_properties.site_id')
         ->leftJoin('property_value_files', 'structures.id', '=', 'property_value_files.entity_id',
            array(
               array('AND' => array(Core_QueryBuilder::expression('`structure_properties`.`property_id`'), '=', Core_QueryBuilder::expression('`property_value_files`.`property_id`')))
            )
         )
         // Идентификатор дополнительного свойства
         ->where(Core_QueryBuilder::expression('`structure_properties`.`property_id`'), '=', '72')
         // Значение дополнительного свойства
         ->where(Core_QueryBuilder::expression('`property_value_files`.`file`'), '!=', '')
         ->groupBy('structures.id')
         // Количество свойств
         ->having(Core_Querybuilder::expression('COUNT(DISTINCT `structure_properties`.`property_id`)'), '>', 0)
         ;


       $Structure_Controller_Show1 ->show();
?>


Запрос при этом получается вот такой:
SELECT * FROM `structures` LEFT OUTER JOIN `structure_properties` ON `structures`.`site_id` = `structure_properties`.`site_id` LEFT OUTER JOIN `property_value_files` ON `structures`.`id` = `property_value_files`.`entity_id` AND `structure_properties`.`property_id` = `property_value_files`.`property_id` WHERE `structures`.`site_id` = '6' AND `active` = 1 AND `siteuser_group_id` IN (0, -1) AND `structure_properties`.`property_id` = '72' AND `property_value_files`.`file` != '' AND `structures`.`deleted` = 0 GROUP BY `structures`.`id` HAVING COUNT(DISTINCT `structure_properties`.`property_id`) > 0 ORDER BY `sorting` ASC, `name` ASC

и результат выдает вполне ожидаемый - именно те элементы структуры, у которых загружен в доп. свойствах файлик.

А при выводе страницы ругается так:
Exception: The property 'property_id' does not exist in the model 'structure'
35 modules/core/exception.php
1287 modules/core/orm.php
753 modules/core/database/mysql.php
675 modules/core/database/mysql.php
476 modules/core/orm.php
383 modules/core/entity.php
192 modules/structure/controller/show.php
74 templates/template44/template.htm
86 modules/template/model.php
137 modules/core/page.php
219 templates/template43/template.htm
86 modules/template/model.php
137 modules/core/page.php
375 modules/core/command/controller/default.php
190 modules/core/router/route.php
205 index.php


74 templates/template44/template.htm
- это та строка, где вызывается
$Structure_Controller_Show1 ->show();


Где у меня ошибка, не пойму... Подскажите, пожалуйста!
Модератор
Re: Работа с дополнительными свойствами в HostCMS v. 6
morrah,
Ваша ошибка в том, что выбирая данные из нескольких таблиц, все они попадают в одну модель, в данном случае в модель структуры, при этом модель структуры не имеет таких атрибутов, как property_id, отсюда Вы и получаете ошибку.
Добавьте ограничение на выборку только из одной таблицы
$Structure_Controller_Show1
         ->structure()
         ->queryBuilder()
         ->select('structures.*')
...
Авторизация