Раздельный вывод "Информационных элементов" в HostCMS.
D270
11 сентября 2017 г.
Вызов
Почему невидим вызов? Уточните пожалуйста, что вы имели ввиду.
<xsl:apply-templates select="property_value[tag_name='8']" mode="master"/>
Почему невидим вызов? Уточните пожалуйста, что вы имели ввиду.
llirik
11 сентября 2017 г.
Это вы вызываете <xsl:template match="property_value" mode="master"> и вызов у вас идет внутри <xsl:template match="informationsystem_item" mode="master"> который у вас в свою очередь нигде не вызывается т.е. должен еще существовать <xsl:apply-templates select="informationsystem_item" mode="master"/> внутри <xsl:template match="/informationsystem">
«Не выходи из комнаты, не совершай ошибку…»
D270
11 сентября 2017 г.
Сделал вызов
Как теперь выводить их [informationsystem id="98" limit="90" group="261" xsl="ВыводМастеров" mode="master"] ?
<?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="/informationsystem"/>
</xsl:template>
<xsl:variable name="n" select="number(3)"/>
<xsl:template match="/informationsystem">
<!-- Получаем ID родительской группы и записываем в переменную $group -->
<xsl:variable name="group" select="group"/>
<!-- Если в находимся корне - выводим название информационной системы -->
<xsl:choose>
<xsl:when test="$group = 0">
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<!-- Отображение подгрупп данной группы, только если подгруппы есть и не идет фильтра по меткам -->
<xsl:if test="count(tag) = 0 and count(.//informationsystem_group[parent_id=$group]) > 0">
<div class="group_list">
<ul>
<xsl:apply-templates select=".//informationsystem_group[parent_id=$group]" mode="groups"/>
</ul>
</div>
</xsl:if>
<!-- Отображение записи информационной системы -->
<xsl:apply-templates select="informationsystem_item" mode="article"/>
<xsl:apply-templates select="informationsystem_item" mode="master"/>
<xsl:choose>
<xsl:when test="$group = 0">
<!-- Описание выводится при отсутствии фильтрации по тэгам -->
<xsl:if test="count(tag) = 0 and page = 0 and description != ''">
<div hostcms:id="{@id}" hostcms:field="description" hostcms:entity="informationsystem" hostcms:type="wysiwyg"><xsl:value-of disable-output-escaping="yes" select="description"/></div>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<!-- Описание выводим только на первой странице -->
<xsl:if test="page = 0 and .//informationsystem_group[@id=$group]/description != ''">
<div hostcms:id="{$group}" hostcms:field="description" hostcms:entity="informationsystem_group" hostcms:type="wysiwyg"><xsl:value-of disable-output-escaping="yes" select=".//informationsystem_group[@id=$group]/description"/></div>
</xsl:if>
<!-- Путь к группе -->
</xsl:otherwise>
</xsl:choose>
<!-- Строка ссылок на другие страницы информационной системы -->
<xsl:if test="ОтображатьСсылкиНаСледующиеСтраницы=1">
<div>
<!-- Ссылка, для которой дописываются суффиксы page-XX/ -->
<xsl:variable name="link">
<xsl:value-of select="/informationsystem/url"/>
<xsl:if test="$group != 0">
<xsl:value-of select="/informationsystem//informationsystem_group[@id = $group]/url"/>
</xsl:if>
</xsl:variable>
<xsl:if test="total > 0 and limit > 0">
<xsl:variable name="count_pages" select="ceiling(total div limit)"/>
<xsl:variable name="visible_pages" select="3"/>
<xsl:variable name="real_visible_pages"><xsl:choose>
<xsl:when test="$count_pages < $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)) < 0">
<xsl:value-of select="page"/>
</xsl:when>
<xsl:when test="($count_pages - page - 1) < 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 > 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) < 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 > 0"><xsl:value-of select="page - $pre_count_page"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose></xsl:variable>
<p>
<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="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="$real_visible_pages"/>
</xsl:call-template>
</p>
</xsl:if>
</div>
</xsl:if>
<xsl:if test="count(informationsystem_group_properties) and group != 0">
<div style="margin: 10px 0px;">
<h2>Атрибуты группы инфоэлементов</h2>
<xsl:if test="count(informationsystem_group[@id = //group]/property[parent_id = 0])">
<table border="0">
<xsl:apply-templates select="informationsystem_group[@id = //group]/property[parent_id = 0]"/>
</table>
</xsl:if>
<xsl:apply-templates select="informationsystem_group_properties"/>
</div>
</xsl:if>
</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property">
<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_path}">Скачать файл</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:template>
<!-- Шаблон выводит рекурсивно ссылки на группы инф. элемента -->
<xsl:template match="informationsystem_group" mode="breadCrumbs">
<xsl:variable name="parent_id" select="parent_id"/>
<xsl:apply-templates select="//informationsystem_group[@id=$parent_id]" mode="breadCrumbs"/>
<xsl:if test="parent_id=0">
<a href="{/informationsystem/url}" hostcms:id="{/informationsystem/@id}" hostcms:field="name" hostcms:entity="informationsystem">
<xsl:value-of disable-output-escaping="yes" select="/informationsystem/name"/>
</a>
</xsl:if>
<span><xsl:text> → </xsl:text></span>
<a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="informationsystem_group">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</xsl:template>
<!-- Шаблон выводит группы свойств для группы инфосистемы -->
<xsl:template match="informationsystem_group_properties">
<p><b><xsl:value-of select="information_propertys_groups_dir_name"/></b></p>
<xsl:variable name="dir_id" select="@id"/>
<xsl:if test="count(//informationsystem_group[@id = //group]/property[parent_id = $dir_id])">
<table border="0">
<xsl:apply-templates select="//informationsystem_group[@id = //group]/property[parent_id = $dir_id]"/>
</table>
</xsl:if>
<xsl:if test="count(informationsystem_group_properties)">
<blockquote>
<xsl:apply-templates select="informationsystem_group_properties"/>
</blockquote>
</xsl:if>
</xsl:template>
<!-- Шаблон выводит ссылки подгруппы информационного элемента -->
<xsl:template match="informationsystem_group" mode="groups">
<!-- <ul>
<xsl:for-each select=". | following-sibling::informationsystem_group[position() < $n]"> -->
<li>
<table>
<tr>
<td style="text-align: center; height: 42px; vertical-align: top;">
<div style="position: relative; width: 0;">
<a href="{url}" style="position: absolute; height: 46px; width: 224px; overflow: hidden;"><xsl:value-of disable-output-escaping="yes" select="name"/></a>
</div>
</td>
</tr>
<tr>
<td style="text-align: center; height: 224px;">
<xsl:if test="image_small != ''">
<a href="{url}"><img src="{dir}{image_small}" align="middle"/></a>
</xsl:if>
<xsl:if test="image_small =''">
<a href="{url}"><img src="/skin/images/master_fake.jpg" align="middle" style="max-width: 224px; max-height: 224px;"/></a>
</xsl:if>
</td>
</tr>
</table>
<a href="{url}" class="link"></a>
</li>
</xsl:template>
<!-- Шаблон вывода информационного элемента -->
<xsl:template match="informationsystem_item" mode="master">
<xsl:apply-templates select="property_value[tag_name='8']" mode="master"/>
</xsl:template>
<xsl:template match="property_value" mode="master">
<div class="item">
<table>
<tr>
<td style="text-align: center; height: 70px; vertical-align: top;">
<div style="position: relative; width: auto;">
<a href="{url}" style="position: relative; height: auto; width: auto; overflow: hidden;"><xsl:value-of disable-output-escaping="yes" select="name"/></a>
</div>
</td>
</tr>
<tr>
<td style="text-align: center; height: 224px; width: 224px;">
<xsl:if test="image_small != ''">
<a href="{url}"><img src="{dir}{image_small}" align="middle"/></a>
</xsl:if>
<xsl:if test="image_small =''">
<a href="{url}"><img src="/skin/images/master_fake.jpg" align="middle" style="max-width: 224px; max-height: 224px;"/></a>
</xsl:if>
</td>
</tr>
</table>
</div>
</xsl:template>
<xsl:template match="informationsystem_item" mode="article">
<xsl:apply-templates select="property_value[tag_name='16']" mode="article"/>
</xsl:template>
<xsl:template match="property_value" mode="article">
<div class="item">
<table>
<tr>
<td style="text-align: center; height: 70px; vertical-align: top;">
<div style="position: relative; width: auto;">
<a href="{url}" style="position: relative; height: auto; width: auto; overflow: hidden;"><xsl:value-of disable-output-escaping="yes" select="name"/></a>
</div>
</td>
</tr>
<tr>
<td style="text-align: center; height: 224px; width: 224px;">
<xsl:if test="image_small != ''">
<a href="{url}"><img src="{dir}{image_small}" align="middle"/></a>
</xsl:if>
<xsl:if test="image_small =''">
<a href="{url}"><img src="/skin/images/master_fake.jpg" align="middle" style="max-width: 224px; max-height: 224px;"/></a>
</xsl:if>
</td>
</tr>
</table>
</div>
</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property_value">
<xsl:variable name="property_id" select="property_id" />
<xsl:variable name="proprety" select="/informationsystem/informationsystem_item_properties/property[@id=$property_id]" />
<xsl:variable name="propretys" select="/informationsystem/informationsystem_item_properties/property_dir/property[@id=$property_id]" />
<xsl:variable name="myparam" select="/informationsystem/informationsystem_item_properties/property_value[@id]" />
<xsl:choose>
<xsl:when test="$proprety/type = 2">
<!--<a href="{/informationsystem/informationsystem_item/dir}{file}">Скачать файл</a>-->
<img src="{/informationsystem/informationsystem_item/dir}{file}" style="width: 100%;"/>
</xsl:when>
<xsl:when test="$propretys/tag_name = 8">
<img src="{/informationsystem/informationsystem_item/dir}{file}" style="width: 100%;"/>
</xsl:when>
<xsl:when test="$propretys/tag_name = 16">
<p style="margin: 2px 0;"><xsl:value-of disable-output-escaping="yes" select="value"/></p>
</xsl:when>
<xsl:when test="$propretys/tag_name = 17">
<td style="float: left;margin: 2px;height: 90px;width: 90px;overflow: hidden;border: 1px solid #BFBFBF;text-align: center;"><a href="{/informationsystem/informationsystem_item/dir}{file}" target="_blank"><img src="{/informationsystem/informationsystem_item/dir}{file}" style="height: 100%;"/></a></td>
</xsl:when>
<xsl:when test="$proprety/type = 7">
<input type="checkbox" disabled="disabled">
<xsl:if test="value = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
</xsl:when>
<xsl:when test="$propretys/type = 7">
<input type="checkbox" disabled="disabled">
<xsl:if test="value = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
</xsl:when>
<xsl:when test="$proprety/type = 1">
<p><xsl:value-of disable-output-escaping="yes" select="value"/></p>
</xsl:when>
<xsl:when test="$proprety/type = 5">
<a href="{/informationsystem/informationsystem_item/property_value/informationsystem_item/url}" target="blank">Прайс</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- /// Метки для информационного элемента /// -->
<xsl:template match="tag">
<a href="{/informationsystem/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 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 > 0"><xsl:value-of select="$page - $pre_count_page"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose></xsl:variable>
<!-- Формирование значений переменных для ссылок -->
<xsl:variable name="group_my" select="/informationsystem/group"/>
<!-- Определяем группу для формирования адреса ссылки -->
<xsl:variable name="group_link_my">
<xsl:choose>
<!-- Если группа не корневая (!=0) -->
<xsl:when test="$group_my != 0">
<xsl:value-of select="/informationsystem//informationsystem_group[@id=$group_my]/url"/>
</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise><xsl:value-of select="/informationsystem/url"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Путь для тэга -->
<xsl:variable name="tag_path_my">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="count(/informationsystem/tag) != 0">tag/<xsl:value-of select="/informationsystem/tag/urlencode"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="prev_number_link_my">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="($page) != 0">page-<xsl:value-of select="$i + 1"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Конец формирования значений переменных для ссылок -->
<xsl:if test="$i = $start_page and $page != 0">
<span class="ctrl"> <a href="{$group_link_my}{$prev_number_link_my}{$tag_path_my}" id="id_prev"><</a>
<!--← Ctrl-->
</span>
</xsl:if>
<xsl:if test="$i = ($page + $post_count_page + 1) and $n != ($page+1)">
<span class="ctrl"> <a href="{$group_link_my}page-{$page+2}/{$tag_path_my}" id="id_next">></a>
<!--Ctrl →-->
</span>
</xsl:if>
<xsl:if test="$items_count > $limit and ($page + $post_count_page + 1) > $i">
<!-- Заносим в переменную $group идентификатор текущей группы -->
<xsl:variable name="group" select="/informationsystem/group"/>
<!-- Путь для тэга -->
<xsl:variable name="tag_path">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="count(/informationsystem/tag) != 0">tag/<xsl:value-of select="/informationsystem/tag/urlencode"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Определяем группу для формирования адреса ссылки -->
<xsl:variable name="group_link">
<xsl:choose>
<!-- Если группа не корневая (!=0) -->
<xsl:when test="$group != 0">
<xsl:value-of select="/informationsystem//informationsystem_group[@id=$group]/url"/>
</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise><xsl:value-of select="/informationsystem/url"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Определяем адрес ссылки -->
<xsl:variable name="number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="$i != 0">page-<xsl:value-of select="$i + 1"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Выводим ссылку на первую страницу -->
<xsl:if test="$page - $pre_count_page > 0 and $i = $start_page">
<a href="{$group_link}{$tag_path}" class="page_link" style="text-decoration: none;">1...</a>
</xsl:if>
<!-- Ставим ссылку на страницу-->
<xsl:if test="$i != $page">
<xsl:if test="($page - $pre_count_page) <= $i and $i < $n">
<!-- Выводим ссылки на видимые страницы -->
<a href="{$group_link}{$number_link}{$tag_path}" class="page_link">
<xsl:value-of select="$i + 1"/>
</a>
</xsl:if>
<!-- Выводим ссылку на последнюю страницу -->
<xsl:if test="$i+1 >= ($page + $post_count_page + 1) and $n > ($page + 1 + $post_count_page)">
<!-- Выводим ссылку на последнюю страницу -->
<a href="{$group_link}page-{$n}/{$tag_path}" class="page_link" style="text-decoration: none;">...<xsl:value-of select="$n"/></a>
</xsl:if>
</xsl:if>
<!-- Ссылка на предыдущую страницу для Ctrl + влево -->
<xsl:if test="$page != 0 and $i = $page">
<xsl:variable name="prev_number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="($page) != 0">page-<xsl:value-of select="$i"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="{$group_link}{$prev_number_link}{$tag_path}" 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}" 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 name="declension">
<xsl:param name="number" select="number"/>
<!-- Именительный падеж -->
<xsl:variable name="nominative">
<xsl:text>комментарий</xsl:text>
</xsl:variable>
<!-- Родительный падеж, единственное число -->
<xsl:variable name="genitive_singular">
<xsl:text>комментария</xsl:text>
</xsl:variable>
<xsl:variable name="genitive_plural">
<xsl:text>комментариев</xsl:text>
</xsl:variable>
<xsl:variable name="last_digit">
<xsl:value-of select="$number mod 10"/>
</xsl:variable>
<xsl:variable name="last_two_digits">
<xsl:value-of select="$number mod 100"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$last_digit = 1 and $last_two_digits != 11">
<xsl:value-of select="$nominative"/>
</xsl:when>
<xsl:when test="$last_digit = 2 and $last_two_digits != 12
or $last_digit = 3 and $last_two_digits != 13
or $last_digit = 4 and $last_two_digits != 14">
<xsl:value-of select="$genitive_singular"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$genitive_plural"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<!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="/informationsystem"/>
</xsl:template>
<xsl:variable name="n" select="number(3)"/>
<xsl:template match="/informationsystem">
<!-- Получаем ID родительской группы и записываем в переменную $group -->
<xsl:variable name="group" select="group"/>
<!-- Если в находимся корне - выводим название информационной системы -->
<xsl:choose>
<xsl:when test="$group = 0">
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<!-- Отображение подгрупп данной группы, только если подгруппы есть и не идет фильтра по меткам -->
<xsl:if test="count(tag) = 0 and count(.//informationsystem_group[parent_id=$group]) > 0">
<div class="group_list">
<ul>
<xsl:apply-templates select=".//informationsystem_group[parent_id=$group]" mode="groups"/>
</ul>
</div>
</xsl:if>
<!-- Отображение записи информационной системы -->
<xsl:apply-templates select="informationsystem_item" mode="article"/>
<xsl:apply-templates select="informationsystem_item" mode="master"/>
<xsl:choose>
<xsl:when test="$group = 0">
<!-- Описание выводится при отсутствии фильтрации по тэгам -->
<xsl:if test="count(tag) = 0 and page = 0 and description != ''">
<div hostcms:id="{@id}" hostcms:field="description" hostcms:entity="informationsystem" hostcms:type="wysiwyg"><xsl:value-of disable-output-escaping="yes" select="description"/></div>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<!-- Описание выводим только на первой странице -->
<xsl:if test="page = 0 and .//informationsystem_group[@id=$group]/description != ''">
<div hostcms:id="{$group}" hostcms:field="description" hostcms:entity="informationsystem_group" hostcms:type="wysiwyg"><xsl:value-of disable-output-escaping="yes" select=".//informationsystem_group[@id=$group]/description"/></div>
</xsl:if>
<!-- Путь к группе -->
</xsl:otherwise>
</xsl:choose>
<!-- Строка ссылок на другие страницы информационной системы -->
<xsl:if test="ОтображатьСсылкиНаСледующиеСтраницы=1">
<div>
<!-- Ссылка, для которой дописываются суффиксы page-XX/ -->
<xsl:variable name="link">
<xsl:value-of select="/informationsystem/url"/>
<xsl:if test="$group != 0">
<xsl:value-of select="/informationsystem//informationsystem_group[@id = $group]/url"/>
</xsl:if>
</xsl:variable>
<xsl:if test="total > 0 and limit > 0">
<xsl:variable name="count_pages" select="ceiling(total div limit)"/>
<xsl:variable name="visible_pages" select="3"/>
<xsl:variable name="real_visible_pages"><xsl:choose>
<xsl:when test="$count_pages < $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)) < 0">
<xsl:value-of select="page"/>
</xsl:when>
<xsl:when test="($count_pages - page - 1) < 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 > 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) < 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 > 0"><xsl:value-of select="page - $pre_count_page"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose></xsl:variable>
<p>
<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="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="$real_visible_pages"/>
</xsl:call-template>
</p>
</xsl:if>
</div>
</xsl:if>
<xsl:if test="count(informationsystem_group_properties) and group != 0">
<div style="margin: 10px 0px;">
<h2>Атрибуты группы инфоэлементов</h2>
<xsl:if test="count(informationsystem_group[@id = //group]/property[parent_id = 0])">
<table border="0">
<xsl:apply-templates select="informationsystem_group[@id = //group]/property[parent_id = 0]"/>
</table>
</xsl:if>
<xsl:apply-templates select="informationsystem_group_properties"/>
</div>
</xsl:if>
</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property">
<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_path}">Скачать файл</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:template>
<!-- Шаблон выводит рекурсивно ссылки на группы инф. элемента -->
<xsl:template match="informationsystem_group" mode="breadCrumbs">
<xsl:variable name="parent_id" select="parent_id"/>
<xsl:apply-templates select="//informationsystem_group[@id=$parent_id]" mode="breadCrumbs"/>
<xsl:if test="parent_id=0">
<a href="{/informationsystem/url}" hostcms:id="{/informationsystem/@id}" hostcms:field="name" hostcms:entity="informationsystem">
<xsl:value-of disable-output-escaping="yes" select="/informationsystem/name"/>
</a>
</xsl:if>
<span><xsl:text> → </xsl:text></span>
<a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="informationsystem_group">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</xsl:template>
<!-- Шаблон выводит группы свойств для группы инфосистемы -->
<xsl:template match="informationsystem_group_properties">
<p><b><xsl:value-of select="information_propertys_groups_dir_name"/></b></p>
<xsl:variable name="dir_id" select="@id"/>
<xsl:if test="count(//informationsystem_group[@id = //group]/property[parent_id = $dir_id])">
<table border="0">
<xsl:apply-templates select="//informationsystem_group[@id = //group]/property[parent_id = $dir_id]"/>
</table>
</xsl:if>
<xsl:if test="count(informationsystem_group_properties)">
<blockquote>
<xsl:apply-templates select="informationsystem_group_properties"/>
</blockquote>
</xsl:if>
</xsl:template>
<!-- Шаблон выводит ссылки подгруппы информационного элемента -->
<xsl:template match="informationsystem_group" mode="groups">
<!-- <ul>
<xsl:for-each select=". | following-sibling::informationsystem_group[position() < $n]"> -->
<li>
<table>
<tr>
<td style="text-align: center; height: 42px; vertical-align: top;">
<div style="position: relative; width: 0;">
<a href="{url}" style="position: absolute; height: 46px; width: 224px; overflow: hidden;"><xsl:value-of disable-output-escaping="yes" select="name"/></a>
</div>
</td>
</tr>
<tr>
<td style="text-align: center; height: 224px;">
<xsl:if test="image_small != ''">
<a href="{url}"><img src="{dir}{image_small}" align="middle"/></a>
</xsl:if>
<xsl:if test="image_small =''">
<a href="{url}"><img src="/skin/images/master_fake.jpg" align="middle" style="max-width: 224px; max-height: 224px;"/></a>
</xsl:if>
</td>
</tr>
</table>
<a href="{url}" class="link"></a>
</li>
</xsl:template>
<!-- Шаблон вывода информационного элемента -->
<xsl:template match="informationsystem_item" mode="master">
<xsl:apply-templates select="property_value[tag_name='8']" mode="master"/>
</xsl:template>
<xsl:template match="property_value" mode="master">
<div class="item">
<table>
<tr>
<td style="text-align: center; height: 70px; vertical-align: top;">
<div style="position: relative; width: auto;">
<a href="{url}" style="position: relative; height: auto; width: auto; overflow: hidden;"><xsl:value-of disable-output-escaping="yes" select="name"/></a>
</div>
</td>
</tr>
<tr>
<td style="text-align: center; height: 224px; width: 224px;">
<xsl:if test="image_small != ''">
<a href="{url}"><img src="{dir}{image_small}" align="middle"/></a>
</xsl:if>
<xsl:if test="image_small =''">
<a href="{url}"><img src="/skin/images/master_fake.jpg" align="middle" style="max-width: 224px; max-height: 224px;"/></a>
</xsl:if>
</td>
</tr>
</table>
</div>
</xsl:template>
<xsl:template match="informationsystem_item" mode="article">
<xsl:apply-templates select="property_value[tag_name='16']" mode="article"/>
</xsl:template>
<xsl:template match="property_value" mode="article">
<div class="item">
<table>
<tr>
<td style="text-align: center; height: 70px; vertical-align: top;">
<div style="position: relative; width: auto;">
<a href="{url}" style="position: relative; height: auto; width: auto; overflow: hidden;"><xsl:value-of disable-output-escaping="yes" select="name"/></a>
</div>
</td>
</tr>
<tr>
<td style="text-align: center; height: 224px; width: 224px;">
<xsl:if test="image_small != ''">
<a href="{url}"><img src="{dir}{image_small}" align="middle"/></a>
</xsl:if>
<xsl:if test="image_small =''">
<a href="{url}"><img src="/skin/images/master_fake.jpg" align="middle" style="max-width: 224px; max-height: 224px;"/></a>
</xsl:if>
</td>
</tr>
</table>
</div>
</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property_value">
<xsl:variable name="property_id" select="property_id" />
<xsl:variable name="proprety" select="/informationsystem/informationsystem_item_properties/property[@id=$property_id]" />
<xsl:variable name="propretys" select="/informationsystem/informationsystem_item_properties/property_dir/property[@id=$property_id]" />
<xsl:variable name="myparam" select="/informationsystem/informationsystem_item_properties/property_value[@id]" />
<xsl:choose>
<xsl:when test="$proprety/type = 2">
<!--<a href="{/informationsystem/informationsystem_item/dir}{file}">Скачать файл</a>-->
<img src="{/informationsystem/informationsystem_item/dir}{file}" style="width: 100%;"/>
</xsl:when>
<xsl:when test="$propretys/tag_name = 8">
<img src="{/informationsystem/informationsystem_item/dir}{file}" style="width: 100%;"/>
</xsl:when>
<xsl:when test="$propretys/tag_name = 16">
<p style="margin: 2px 0;"><xsl:value-of disable-output-escaping="yes" select="value"/></p>
</xsl:when>
<xsl:when test="$propretys/tag_name = 17">
<td style="float: left;margin: 2px;height: 90px;width: 90px;overflow: hidden;border: 1px solid #BFBFBF;text-align: center;"><a href="{/informationsystem/informationsystem_item/dir}{file}" target="_blank"><img src="{/informationsystem/informationsystem_item/dir}{file}" style="height: 100%;"/></a></td>
</xsl:when>
<xsl:when test="$proprety/type = 7">
<input type="checkbox" disabled="disabled">
<xsl:if test="value = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
</xsl:when>
<xsl:when test="$propretys/type = 7">
<input type="checkbox" disabled="disabled">
<xsl:if test="value = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
</xsl:when>
<xsl:when test="$proprety/type = 1">
<p><xsl:value-of disable-output-escaping="yes" select="value"/></p>
</xsl:when>
<xsl:when test="$proprety/type = 5">
<a href="{/informationsystem/informationsystem_item/property_value/informationsystem_item/url}" target="blank">Прайс</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- /// Метки для информационного элемента /// -->
<xsl:template match="tag">
<a href="{/informationsystem/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 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 > 0"><xsl:value-of select="$page - $pre_count_page"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose></xsl:variable>
<!-- Формирование значений переменных для ссылок -->
<xsl:variable name="group_my" select="/informationsystem/group"/>
<!-- Определяем группу для формирования адреса ссылки -->
<xsl:variable name="group_link_my">
<xsl:choose>
<!-- Если группа не корневая (!=0) -->
<xsl:when test="$group_my != 0">
<xsl:value-of select="/informationsystem//informationsystem_group[@id=$group_my]/url"/>
</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise><xsl:value-of select="/informationsystem/url"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Путь для тэга -->
<xsl:variable name="tag_path_my">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="count(/informationsystem/tag) != 0">tag/<xsl:value-of select="/informationsystem/tag/urlencode"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="prev_number_link_my">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="($page) != 0">page-<xsl:value-of select="$i + 1"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Конец формирования значений переменных для ссылок -->
<xsl:if test="$i = $start_page and $page != 0">
<span class="ctrl"> <a href="{$group_link_my}{$prev_number_link_my}{$tag_path_my}" id="id_prev"><</a>
<!--← Ctrl-->
</span>
</xsl:if>
<xsl:if test="$i = ($page + $post_count_page + 1) and $n != ($page+1)">
<span class="ctrl"> <a href="{$group_link_my}page-{$page+2}/{$tag_path_my}" id="id_next">></a>
<!--Ctrl →-->
</span>
</xsl:if>
<xsl:if test="$items_count > $limit and ($page + $post_count_page + 1) > $i">
<!-- Заносим в переменную $group идентификатор текущей группы -->
<xsl:variable name="group" select="/informationsystem/group"/>
<!-- Путь для тэга -->
<xsl:variable name="tag_path">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="count(/informationsystem/tag) != 0">tag/<xsl:value-of select="/informationsystem/tag/urlencode"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Определяем группу для формирования адреса ссылки -->
<xsl:variable name="group_link">
<xsl:choose>
<!-- Если группа не корневая (!=0) -->
<xsl:when test="$group != 0">
<xsl:value-of select="/informationsystem//informationsystem_group[@id=$group]/url"/>
</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise><xsl:value-of select="/informationsystem/url"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Определяем адрес ссылки -->
<xsl:variable name="number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="$i != 0">page-<xsl:value-of select="$i + 1"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Выводим ссылку на первую страницу -->
<xsl:if test="$page - $pre_count_page > 0 and $i = $start_page">
<a href="{$group_link}{$tag_path}" class="page_link" style="text-decoration: none;">1...</a>
</xsl:if>
<!-- Ставим ссылку на страницу-->
<xsl:if test="$i != $page">
<xsl:if test="($page - $pre_count_page) <= $i and $i < $n">
<!-- Выводим ссылки на видимые страницы -->
<a href="{$group_link}{$number_link}{$tag_path}" class="page_link">
<xsl:value-of select="$i + 1"/>
</a>
</xsl:if>
<!-- Выводим ссылку на последнюю страницу -->
<xsl:if test="$i+1 >= ($page + $post_count_page + 1) and $n > ($page + 1 + $post_count_page)">
<!-- Выводим ссылку на последнюю страницу -->
<a href="{$group_link}page-{$n}/{$tag_path}" class="page_link" style="text-decoration: none;">...<xsl:value-of select="$n"/></a>
</xsl:if>
</xsl:if>
<!-- Ссылка на предыдущую страницу для Ctrl + влево -->
<xsl:if test="$page != 0 and $i = $page">
<xsl:variable name="prev_number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="($page) != 0">page-<xsl:value-of select="$i"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="{$group_link}{$prev_number_link}{$tag_path}" 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}" 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 name="declension">
<xsl:param name="number" select="number"/>
<!-- Именительный падеж -->
<xsl:variable name="nominative">
<xsl:text>комментарий</xsl:text>
</xsl:variable>
<!-- Родительный падеж, единственное число -->
<xsl:variable name="genitive_singular">
<xsl:text>комментария</xsl:text>
</xsl:variable>
<xsl:variable name="genitive_plural">
<xsl:text>комментариев</xsl:text>
</xsl:variable>
<xsl:variable name="last_digit">
<xsl:value-of select="$number mod 10"/>
</xsl:variable>
<xsl:variable name="last_two_digits">
<xsl:value-of select="$number mod 100"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$last_digit = 1 and $last_two_digits != 11">
<xsl:value-of select="$nominative"/>
</xsl:when>
<xsl:when test="$last_digit = 2 and $last_two_digits != 12
or $last_digit = 3 and $last_two_digits != 13
or $last_digit = 4 and $last_two_digits != 14">
<xsl:value-of select="$genitive_singular"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$genitive_plural"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Как теперь выводить их [informationsystem id="98" limit="90" group="261" xsl="ВыводМастеров" mode="master"] ?
llirik
11 сентября 2017 г.
[informationsystem id="98" limit="90" group="261" xsl="название_xsl" ] разделение у вас должно идти внутри самого xsl, никаких mode в вызове шорткода нет.
«Не выходи из комнаты, не совершай ошибку…»
D270
11 сентября 2017 г.
В таком случае информационные элементы не выводятся совсем. Видимо теперь нужно с доп.свойствами решать?
llirik
11 сентября 2017 г.
В ваших <xsl:template match="informationsystem_item" mode="..."> не видим вывода информации о инфо элементах.
«Не выходи из комнаты, не совершай ошибку…»
Авторизация