Добрый день. Как заменить при выводе текста (контента) информационного элемента условно введенный мною тег <gallery></gallery> на галерею картинок, выбираемых из дополнительных свойств? Суть: хочу в любом месте контента ее отображать.
Что имеентся:
Подготавливаем разметку для галереи и сохраняем в переменную:
<xsl:variable name="gallery">
<xsl:call-template name="gallery">
<xsl:with-param name="directory" select="$directory"/>
</xsl:call-template>
</xsl:variable>
<xsl:template name="gallery">
<xsl:param name="directory"/>
<xsl:if test="count(property_value[tag_name='additional_images'])">
<div id="lightgallery">
<xsl:for-each select="property_value[tag_name='additional_images']">
<a href="{$directory}{file}" class="thumbnail">
<img src="{$directory}{file_small}" class="thumbnail__img" title="{file_description}" alt="{file_description}"/>
<div class="demo-gallery-poster">
<img src="/images/zoom.png"/>
</div>
</a>
</xsl:for-each>
</div>
</xsl:if>
</xsl:template>
Замена:
<xsl:variable name="myVariable">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="text" />
<xsl:with-param name="replace" select="'<gallery></gallery>'" />
<xsl:with-param name="by" select="$gallery"/> Полагаю основная проблема в том, что здесь не строка, а ноды, но как превратить в строку мыслей нет
</xsl:call-template>
</xsl:variable>
<xsl:value-of disable-output-escaping="yes" select="$myVariable"/>
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)" />
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>