multi-node tree picker with unpublished items gives an error..
Hey guys,
i have a multi-node tree picker... It works great.
Now i have selected 4 items in my picker and i have an xslt that reads the selected items from the picker.. Nothing wrong here...
But if an editor tries to unpublish an item in the CMS which is selected in the multi-node tree picker... the page that uses this xslt breaks, because the picker doesnt know that the page is unpublished.. The question is how can i modify my xslt looping thru the items in the picker which takes into account if the page is published or not..
thanks in advance guys..
<xsl:for-each select="$currentPage/highlights//nodeId"> <xsl:variable name="page" select="umbraco.library:GetXmlNodeById(.) " /> <!-- am doing something here with the page variable --> </xsl:for-each>
Check the @id attribute after you've assigned the page variable, if it doesn't hold a value, it's not published! Or, check whether the method GetXmlNodeById returns an error xml fragment (Don't know the syntax by heard unfortunately...). Anyway, in those rare cases, I do a xsl:copy-of inside a textarea to find out what's in a variable
<xsl:for-eachselect="$currentPage/highlights//nodeId"> <xsl:variablename="page"select="umbraco.library:GetXmlNodeById(.) "/>
<textarea><xsl:copy-of select="$page" /></textarea>
<!-- am doing something here with the page variable -->
</xsl:for-each>
Thanks alot Dirk... ur pointers helped me a lot.. Indeed there is an <error> xml tag being generated when the page is not published.. so i use that.. thanks again..
multi-node tree picker with unpublished items gives an error..
Hey guys,
i have a multi-node tree picker... It works great.
Now i have selected 4 items in my picker and i have an xslt that reads the selected items from the picker.. Nothing wrong here...
But if an editor tries to unpublish an item in the CMS which is selected in the multi-node tree picker... the page that uses this xslt breaks, because the picker doesnt know that the page is unpublished.. The question is how can i modify my xslt looping thru the items in the picker which takes into account if the page is published or not..
thanks in advance guys..
Hi Wiske80,
Check the @id attribute after you've assigned the page variable, if it doesn't hold a value, it's not published! Or, check whether the method GetXmlNodeById returns an error xml fragment (Don't know the syntax by heard unfortunately...). Anyway, in those rare cases, I do a xsl:copy-of inside a textarea to find out what's in a variable
Hope this helps.
Regards,
/Dirk
Thanks alot Dirk... ur pointers helped me a lot.. Indeed there is an <error> xml tag being generated when the page is not published.. so i use that.. thanks again..
He's one I got working
<xsl:if test="$page/@id != ''"></xsl:if>
Arround the <li> tag fixes it
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " ">]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml
umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes
Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings
Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes" indent="no" />
<xsl:param name="currentPage"/>
<xsl:variable name="rootPage" select="$currentPage/ancestor-or-self::root/CWS-Home/primaryNavigation"/>
<xsl:template match="/">
<!--
uComponents: Multi-node Tree Picker - An XSLT example
=====================================
The Multi-node Tree Picker data-type will provide XML data based on the nodes you have selected.
In this example, the property alias name for the Multi-node Tree Picker is "rootPage".
-->
<xsl:if test="$rootPage != ''">
<xsl:variable name="nodeIds" select="umbraco.library:Split($rootPage,',')" />
<xsl:variable name="currentid" select="$currentPage/@id"/>
<ul id="primary-nav" class="nav navbar-nav">
<xsl:for-each select="$nodeIds/value">
<xsl:variable name="page" select="umbraco.library:GetXmlNodeById(current()/.)"/>
<xsl:if test="$page/@id != ''">
<li>
variable name="link">
<xsl:value-of disable-output-escaping="yes" select="umbraco.library:NiceUrl($page/@id)" />
</xsl:variable>
<a href="{Exslt.ExsltStrings:lowercase($link)}">
<span select="$page/@nodeName" disable-output-escaping="yes"/>
<xsl:value-of>
</span>
</a>
</li>
</xsl:if>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
is working on a reply...