2012-02-03 193 views
1

我有一個帶有兩個複選框的複選框列表。我希望在檢查其中任何一個時輸出鏈接。這兩個複選框可以同時檢查,或者只檢查一個,或根本沒有。從複選框列表中選擇複選框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> 

回答

1

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> 

希望,這是卓有成效的爲您服務。顯然,更新任何對顏色及其價值的引用以適應您的具體情況。

+0

這工作正常,非常感謝。選擇一個選中的「真/假」框很簡單,但這絕對是棘手的!再次,謝謝一堆! – 2012-02-03 12:13:25