Для вывода информации через шаблон создадим следующую структуру
Создадим в xsltTpls/layaouts/banner.xsl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY mdash "—"> <!ENTITY nbsp " ">]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umi="http://www.umi-cms.ru/TR/umi" xmlns:php="http://php.net/xsl" xmlns:math="http://exslt.org/math" extension-element-prefixes="math"> <xsl:template match="result" mode="banner"> <xsl:if test="document(concat('upage://',@pageId))/udata//property[@name = 'status']/value"> <div class="slider swiper-container slider--full slider--text"> <?php /*slider--text */?> <div class="slider__slides swiper-wrapper"> <xsl:if test="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='banner_1']/value/@path"> <div class="slider__slide swiper-slide" style="background-image: url('{document(concat('udata://system/makeThumbnail/(',document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='banner_1']/value/@path,')/(auto)/440'))/udata/src}')"> <div> <p class=" slider__text slider__text--title"> <xsl:value-of select="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='zagolovok_1']/value" /> </p> <p class="slider__text"> <xsl:value-of select="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='tekst_1']/value" disable-output-escaping="yes" /> </p> </div> <xsl:if test="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='ssylka_1']/value"> <a href="{document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='ssylka_1']/value}" style="z-index:1000;" target="_blank"> </a> </xsl:if> </div> </xsl:if> <xsl:if test="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='banner_2']/value/@path"> <div class="slider__slide swiper-slide" style="background-image: url('{document(concat('udata://system/makeThumbnail/(',document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='banner_2']/value/@path,')/(auto)/440'))/udata/src}')"> <div> <p class=" slider__text slider__text--title"> <xsl:value-of select="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='zagolovok_2']/value" /> </p> <p class="slider__text"> <xsl:value-of select="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='tekst_2']/value" disable-output-escaping="yes" /> </p> </div> <xsl:if test="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='ssylka_2']/value"> <a href="{document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='ssylka_2']/value}" target="_blank"></a> </xsl:if> </div> </xsl:if> </div> <div class="slider__controls"> <span class="slider__prev icon-arrow-left"/> <span class="slider__next icon-arrow-right"/> </div> </div> </xsl:if> </xsl:template> <xsl:template match="result" mode="main_banner"> <xsl:if test="document(concat('upage://',@pageId))/udata//property[@name = 'status']/value"> <div class="slider swiper-container"> <div class="slider__slides swiper-wrapper"> <xsl:if test="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='banner_1']/value/@path"> <div class="slider__slide swiper-slide" style="background-image: url('{document(concat('udata://system/makeThumbnail/(',document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='banner_1']/value/@path,')/(auto)/500'))/udata/src}');"> <div> <p class=" slider__text slider__text--title"><xsl:value-of select="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='zagolovok_1']/value" /></p> <p class="slider__text"><xsl:value-of select="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='tekst_1']/value" disable-output-escaping="yes" /></p> </div> <a href="{document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='ssylka_1']/value}"> </a> </div> </xsl:if> <xsl:if test="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='banner_2']/value/@path"> <div class="slider__slide swiper-slide" style="background-image: url('{document(concat('udata://system/makeThumbnail/(',document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='banner_2']/value/@path,')/(auto)/500'))/udata/src}');"> <div> <p class=" slider__text slider__text--title"><xsl:value-of select="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='zagolovok_2']/value" /></p> <p class="slider__text"><xsl:value-of select="document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='tekst_2']/value" disable-output-escaping="yes" /></p> </div> <a href="{document(concat('upage://',@pageId))/udata/page/properties/group[@name='banners']/property[@name='ssylka_2']/value}"> </a> </div> </xsl:if> </div> <div class="slider__controls"> <span class="slider__prev icon-arrow-left"/> <span class="slider__next icon-arrow-right"/> </div> </div> </xsl:if> </xsl:template> </xsl:stylesheet> |
Для вывода используем
1 |
<xsl:apply-templates select="/" mode="main_banner" /> |
В начале документа не забываем
1 |
<xsl:include href="layouts/banner.xsl"/> |