I am trying to use the breadcrumb template that is built in to umbraco. I let my users select a new link name or if they leave that field blank, then it uses the pageName. For my print currentpage section of the Breadcrumb, I would like to be able to check if the 'linkText' is not equal to null, then print the link text. If it is null or empty then print the currentPage/@nodeName.
Maybe you could give some information about what exactkly is the problem you are experiencing (error, text is blank, ...)? It might help getting in the goor direction to search for.
I think the function you are looking for is string-length(). You can use that to check if a property has anything in it. You could also use a case when instead of an if (as that supports an else).
Breadcrumb xslt currentpage Issue
I am trying to use the breadcrumb template that is built in to umbraco. I let my users select a new link name or if they leave that field blank, then it uses the pageName. For my print currentpage section of the Breadcrumb, I would like to be able to check if the 'linkText' is not equal to null, then print the link text. If it is null or empty then print the currentPage/@nodeName.
Here is my code:
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="minLevel" select="1"/>
<xsl:template match="/">
<xsl:if test="$currentPage/@level > $minLevel">
<ul>
<xsl:for-each select="$currentPage/ancestor::node [@level > $minLevel and string(data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a> »
</li>
</xsl:for-each>
<!-- print currentpage -->
<li> <xsl:value-of select="data [@alias = 'linkText']"/>
<xsl:if test="data [@alias='linkText'] = ''">
<xsl:value-of select="$currentPage/@nodeName"/>
</xsl:if>
<xsl:if test="data [@alias='linkText'] != ''">
<xsl:value-of select="data [@alias='linkText']" />
</xsl:if>
</li>
</ul>
</xsl:if>
</xsl:template>
Hi Lisa,
Maybe you could give some information about what exactkly is the problem you are experiencing (error, text is blank, ...)? It might help getting in the goor direction to search for.
Cheers,
Michael.
I think the function you are looking for is string-length(). You can use that to check if a property has anything in it. You could also use a case when instead of an if (as that supports an else).
So the code to would be:
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="minLevel" select="1"/>
<xsl:template match="/">
<xsl:if test="$currentPage/@level > $minLevel">
<ul>
<xsl:for-each select="$currentPage/ancestor::node [@level > $minLevel and string(data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a> »
</li>
</xsl:for-each>
<!-- print currentpage -->
<li>
<xsl:choose>
<xsl:when test="string-length($currentPage/data [@alias='linkText']) > 0">
<xsl:value-of select="$currentPage/data [@alias='linkText']"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$currentPage/@nodeName"/>
</xsl:otherwise>
</xsl:choose>
</li>
</ul>
</xsl:if>
</xsl:template>
Hope that helps!
Thank you Tim...this worked perfectly.
is working on a reply...