Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kevon K. Hayes 255 posts 280 karma points
    Nov 17, 2010 @ 16:48
    Kevon K. Hayes
    0

    Get Property based on if property is null "" or not

    I have a Parent Node that represents a Menu and all the childnodes of Menu are "Menu Items". Each Menu Item has 2 properties: 

    1) Content Picker (alias is "corCPURL")

    2) Textstring (alias is "corURL")

    I would to create an xslt macro that gets the value of "corCPURL" if "cpURL" is null or equal to "".

    Below is the xslt I have so far any help would be appreciated.

    I have a Parent Node that represents a Menu and all the childnodes of Menu are "Menu Items". Each Menu Item has 2 properties: 

    1) Content Picker (alias is "corCPURL")

    2) Textstring (alias is "corURL")

    I would to create an xslt macro that gets the value of "corCPURL" if "cpURL" is null or equal to "".

    Below is the xslt I have so far any help would be appreciated.

    <xsl:template match="/">
      <!--This gets the ID of the MenuItemContainer-->
    <xsl:variable name="id" select="$currentPage/corMenuID" />
    <ul>   
    <!--- Getting the Menu Items in the Container-->
    <xsl:for-each select="umbraco.library:GetXmlNodeById($id)/corMenuItem [@isDoc]">
    <!-- Setting variable to get the text value from corURL property --><xsl:variable name="corURLValue" select="umbraco.library:Item($currentPage/@id, 'corURL')" />

        <xsl:choose>
          <!-- if the value of the corCPURL is null or "" output the value of corURL property-->
          <xsl:when test="$corURLValue != ''">
            <li>
              <a href="{corURL}">
                <xsl:value-of select="@nodeName"/>
              </a>
            </li>
          </xsl:when>
          <!-- otherwise output the URL from the content picker corCPURL-->
          <xsl:otherwise>
            <li>
              <a href="umbraco.library:NiceUrl(corCPURL)">
              <xsl:value-of select="@nodeName"/>
              </a>
            </li>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each>
    </ul>
    </xsl:template>

     

     

     

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies