简体   繁体   English

从复选框列表中选择复选框xsl umbraco

[英]Select check box from check box list xsl umbraco

I have a check box list with two check boxes. 我有一个带有两个复选框的复选框列表。 I want to output a link when either of them are checked. 我想在检查其中任何一个时输出链接。 Both check boxes can be checked at the same time, or just one checked, or none at all. 可以同时选中两个复选框,或者只选中一个复选框,或者根本不选中。

I have aa variable named value where I am getting the dataType 2084 which is the check box list. 我有一个名为value的变量,在其中我获得了dataType 2084,这是复选框列表。

How can I target an individual check box within the list when it is checked. 选中复选框后,如何定位列表中的单个复选框。 There preValues are 99 and 101. preValue有99和101。

Anyone who can help I am very much thankful! 任何能帮助我的人都非常感谢!

Here is my attempt below. 这是我在下面的尝试。

<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 returns a data set for the umbraco raw data type, not the status if they're checked or not on any particular content node. GetPreValues返回umbraco原始数据类型的数据集,而不是状态(如果已在任何特定内容节点上选中或未选中它们)。

Assumptions (as not specified in question): 假设(未明确说明):

Your data type is going to look something like the following: 您的数据类型将如下所示:

<preValues>
    <preValue id="99">Red</preValue>
    <preValue id="100">Green</preValue>
    <preValue id="101">Blue</preValue>
</preValues>

Not knowing the property alias you gave the checkbox list when adding the data type to the document type, I'm just going to use the following 将数据类型添加到文档类型时,不知道您为复选框列表指定的属性别名,我将使用以下内容

MarkerItem/colours

Code: 码:

This code was written on the fly, so haven't had time to test it. 该代码是即时编写的,因此没有时间对其进行测试。

<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>

Hopefully, that does the trick for you. 希望这对您有用。 Obviously, update any reference to colours and their value to what is specific to you. 显然,将对颜色及其值的任何引用更新为特定于您的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM