我从 Umbraco 的宏中获取图像文件夹参数(媒体部分中的文件夹),然后循环遍历所有图像。首先我检查该文件夹是否为空,然后在循环期间我进一步尝试检查图像名称是否等于“marhall_spadayhpbanner_jul131%20(4).jpg”,然后我需要放置一个不同的链接到锚点。我尝试了以下 xslt 代码,但由于某种原因,它没有按预期工作,并且第二个条件(当图像等于 'media/42595/marhall_spadayhpbanner_jul131%20(4).jpg' 时)永远不会正确。
任何想法谢谢
<xsl:for-each select="$imageFolderContents/node [@nodeTypeAlias='Image']">
<xsl:if test="string(current()/data [@alias='umbracoFile']) != ''">
<a href="www.somelink.com">
<img alt="{current()/@nodeName}">
<xsl:attribute name="src"><xsl:value-of select="current()/data [@alias='umbracoFile']"/></xsl:attribute>
</img>
</a>
</xsl:if>
<xsl:if test="string(current()/data [@alias='umbracoFile']) = 'media/42595/marhall_spadayhpbanner_jul131%20(4).jpg'">
<a href="someotherlink.com">
<img alt="{current()/@nodeName}">
<xsl:attribute name="src"><xsl:value-of select="current()/data [@alias='umbracoFile']"/></xsl:attribute>
</img>
</a>
</xsl:if>
</xsl:for-each>
输出是代码是
<div style="clear: both; position: relative; height: auto;" class="slideshow innerfade"><a href="http://gifts.skchase.com/marhall/summerspa/" style="z-index: 5; position: absolute; display: none;"><img alt="dont be a fool" src="/media/42595/marhall_spadayhpbanner_jul131 (4).jpg"></a><a href="https://gifts.skchase.com/marhall/summerspa/" style="z-index: 4; position: absolute; display: block;"><img alt="dont be a fool" src="/media/42595/marhall_spadayhpbanner_jul131 (4).jpg"></a><a href="http://gifts.skchase.com/marhall/summerspa/" style="z-index: 3; position: absolute; display: none;"><img alt="MH-Ext-16-hero.jpg" src="/media/1548/MH-Ext-16-hero.jpg"></a><a href="http://gifts.skchase.com/marhall/summerspa/" style="z-index: 2; position: absolute; display: none;"><img alt="golf_hero_arial_new.jpg" src="/media/1816/golf_hero_arial_new.jpg"></a><a href="http://gifts.skchase.com/marhall/summerspa/" style="z-index: 1; position: absolute; display: none;"><img alt="MH-Spa-e-25-hero.jpg" src="/media/1552/MH-Spa-e-25-hero.jpg"></a></div>