从复选框列表中选择复选框xsl umbraco
问题描述:
我有一个带有两个复选框的复选框列表。我希望在检查其中任何一个时输出链接。这两个复选框可以同时检查,或者只检查一个,或根本没有。从复选框列表中选择复选框xsl umbraco
我有一个变量命名值,我得到的数据类型2084是复选框列表。
如何在检查时定位列表中的单个复选框。有preValues是99和101.
任何人都可以帮助我非常感谢!
下面是我的下面的尝试。
<xsl:param name="currentPage"/>
<xsl:param name="parentNode" select="/macro/parentNode"/>
<xsl:template match="/">
<xsl:for-each select="$currentPage/OperationsMap[@id=$parentNode]/MarkerItem">
<xsl:variable name="value" select="umbraco.library:GetPreValues('2084')"/>
<div class="popup-box">
<xsl:if test="$value/preValue[@alias='99'] = '1'">
<div class="colorbox-link-container">
<a href="#" class="colorboxLink">View current gallery</a>
</div>
</xsl:if>
<xsl:if test="$value/preValue[@alias='101'] = '1'">
<div class="colorbox-link-container">
<a href="#" class="colorboxLink">View historical project progress</a>
</div>
</xsl:if>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
答
GetPreValues
返回了一把umbraco原始数据类型的数据集,而不是如果他们选中或不属于任何特定内容节点上的状态。
假设(如在问题未指定):
你的数据类型是要看起来像如下:
<preValues>
<preValue id="99">Red</preValue>
<preValue id="100">Green</preValue>
<preValue id="101">Blue</preValue>
</preValues>
不知道添加的时候你给复选框列表属性别名数据类型为文档类型,我将使用以下内容
MarkerItem/colours
代码:
此代码是即时编写的,所以没有时间去测试它。
<xsl:for-each select="$currentPage/OperationsMap[@id=$parentNode]/MarkerItem">
<div class="popup-box">
<!-- get the colours checked on MarkerItem -->
<xsl:variable name="colours" select="./colours"/>
<xsl:variable name="coloursValues" select="umbraco.library:Split($colours, ',')" />
<!-- cycle through each of the checked colours -->
<xsl:for-each select="$coloursValues/value">
<xsl:choose>
<xsl:when test=". = 'Red'">
<div class="colorbox-link-container">
<a href="#" class="colorboxLink">View current gallery</a>
</div>
</xsl:when>
<xsl:when test=". = 'Blue'">
<div class="colorbox-link-container">
<a href="#" class="colorboxLink">View historical project progress</a>
</div>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</div>
希望,这是卓有成效的为您服务。显然,更新任何对颜色及其价值的引用以适应您的具体情况。
这工作正常,非常感谢。选择一个选中的“真/假”框很简单,但这绝对是棘手的!再次,谢谢一堆! – 2012-02-03 12:13:25