<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-->
I replicated your setup and had it working nicely. If you want you could send me login credentials for your Umbraco and I will help you make it work. Please mail me at media AT tidmand DOT com.
and put it right after the xsl:template and before the ul. This will output the xml structure based on the id picked from alias "corMenuID" of the currentPage.
FYI, anyone following this thread. If you change your alias names for your properties, do yourself a favor and refresh the XML cache by re-publishing dependent nodes or republish the entire site. If you do not do this the side effects will be your Macros won't render. Obvious now wasn't before!
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.
Hi Kevon.
I've tried to narrow down your wish to the following lines of code. I hope it solves your problem. Otherwise get back to me.
All the best,
Søren
<!-- This gets the ID of the MenuItemContainer -->
<xsl:variable name="menuRoot" select="umbraco.library:GetXmlNodeById($currentPage/corMenuID)" />
<xsl:template match="/">
<ul>
<!--- Getting the Menu Items in the Container-->
<xsl:apply-templates select="$menuRoot/corMenuItem" />
</ul>
</xsl:template>
<!-- catch alle menu items where corURL isn't empty -->
<xsl:template match="corMenuItem[corURL!='']">
<li>
<!-- as these URL's probably will point to external web pages, I've included target="_blank" -->
<a href="{corURL}" target="_blank" title="{@nodeName}"><xsl:value-of select="@nodeName" /></a>
</li>
</xsl:template>
<xsl:template match="*">
<li>
<!-- otherwise output the URL from the content picker corCPURL -->
<a href="{umbraco.library:NiceUrl(corCPURL)}" title="{@nodeName}"><xsl:value-of select="@nodeName" /></a>
</li>
</xsl:template>
Output is blank... Looks like I'll be recreating this macro using .NET.
Hi Kevon,
I replicated your setup and had it working nicely. If you want you could send me login credentials for your Umbraco and I will help you make it work. Please mail me at media AT tidmand DOT com.
Best regards,
Søren
OK I'll try it once again. Did you wrap your solution in an xsl:template? I was wondering because you have 3?.
Yep. You have to wrap it in an xslt, so place the above written code between
and
and see if that does the trick.
If you need to be sure that there is an output at all from the variable, you could try to make a copy-of like this
and put it right after the xsl:template and before the ul. This will output the xml structure based on the id picked from alias "corMenuID" of the currentPage.
Please let me know how it goes.
/Søren
I emailed you the URL and credentials... let me know where my mistake was.
FYI, anyone following this thread. If you change your alias names for your properties, do yourself a favor and refresh the XML cache by re-publishing dependent nodes or republish the entire site. If you do not do this the side effects will be your Macros won't render. Obvious now wasn't before!
is working on a reply...