Tryin to output the value of custom property if another property is null
The the "otherwise" block works but not the "when" block.
<xsl:template match="/"> <!-- Creating ID of the Menu Container --> <xsl:variable name="id" select="$currentPage/corMenuItemsID" /> <ul> <!--- Getting the Menu Items in the Container--> <xsl:for-each select="umbraco.library:GetXmlNodeById($id)/corDeptMenuItem [@isDoc]"> <!-- Setting variable to get the URL from below property --> <xsl:variable name="theURL" select="umbraco.library:NiceUrl(corDeptMenuItemLink)" /> <!-- Setting variable to get the text value from below property --> <xsl:variable name="corURLValue" select="umbraco.library:Item($currentPage/@id, 'corURL')" /> <xsl:choose> <!-- if the value of the corDeptMenuItemLink is null or "" output the value of corURL property--> <xsl:when test="theURL = ''"> <li> <a href="corURLValue"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:when> <!-- otherwise output the URL of the value of the URL of the corDeptMenuItemLink property--> <xsl:otherwise> <li> <a href="{umbraco.library:NiceUrl(corDeptMenuItemLink)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:otherwise> </xsl:choose> </xsl:for-each> </ul> </xsl:template>
<xsl:template match="/"> <!-- Creating ID of the Menu Container --> <xsl:variable name="id" select="$currentPage/corMenuItemsID" /> <ul> <!--- Getting the Menu Items in the Container--> <xsl:for-each select="umbraco.library:GetXmlNodeById($id)/corDeptMenuItem [@isDoc]"> <!-- Setting variable to get the URL from below property --> <xsl:variable name="theURL" select="umbraco.library:NiceUrl(corDeptMenuItemLink)" /> <!-- Setting variable to get the text value from below property --> <xsl:variable name="corURLValue" select="umbraco.library:Item($currentPage/@id, 'corURL')" /> <xsl:choose> <!-- if the value of the corDeptMenuItemLink is null or "" output the value of corURL property--> <xsl:when test="$theURL = ''"> <li> <a href="$corURLValue"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:when> <!-- otherwise output the URL of the value of the URL of the corDeptMenuItemLink property--> <xsl:otherwise> <li> <a href="{umbraco.library:NiceUrl(corDeptMenuItemLink)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:otherwise> </xsl:choose> </xsl:for-each> </ul> </xsl:template>
I actually fixed that however now all is working except one thing The url of the of the content picker always links to the parent page id "Testing2" as shown below no matter what content node I choose in the picker
Tryin to output the value of custom property if another property is null
The the "otherwise" block works but not the "when" block.
<xsl:template match="/">
<!-- Creating ID of the Menu Container -->
<xsl:variable name="id" select="$currentPage/corMenuItemsID" />
<ul>
<!--- Getting the Menu Items in the Container-->
<xsl:for-each select="umbraco.library:GetXmlNodeById($id)/corDeptMenuItem [@isDoc]">
<!-- Setting variable to get the URL from below property -->
<xsl:variable name="theURL" select="umbraco.library:NiceUrl(corDeptMenuItemLink)" />
<!-- Setting variable to get the text value from below property -->
<xsl:variable name="corURLValue" select="umbraco.library:Item($currentPage/@id, 'corURL')" />
<xsl:choose>
<!-- if the value of the corDeptMenuItemLink is null or "" output the value of corURL property-->
<xsl:when test="theURL = ''">
<li>
<a href="corURLValue">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<!-- otherwise output the URL of the value of the URL of the corDeptMenuItemLink property-->
<xsl:otherwise>
<li>
<a href="{umbraco.library:NiceUrl(corDeptMenuItemLink)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ul>
</xsl:template>
Hi,
On quick look i see you are calling your variables (theURL and corURLValue) vithout $ sign.
Could that be the problem?
I made the suggested change.. still no output.
This is the node structure
This is the where if the Item Link value hasn't been selected/blank/null then i'd like to choose the value of the URL property.
The code looks lke this so far:
Hi,
so what exactly is not working in when block?
In your code i see that you are calling $corURLValue variable without curly braces in the href attribute.
That will result in not getting a property from page.
Could that be your problem?
I actually fixed that however now all is working except one thing The url of the of the content picker always links to the parent page id "Testing2" as shown below no matter what content node I choose in the picker
Here's the updated XSLT:
is working on a reply...