Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I'm using the following xsl:choose statement to check for the "metaTItle" field in my master document type, it is constantly returning null. Am I missing something?
Thanks!
Amir
<xsl:choose><xsl:when test="$currentPage/data[@alias='metaTitle'] != 0"> Hello! </xsl:when> <xsl:otherwise> Goodbye! </xsl:otherwise></xsl:choose>
Got 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"/><xsl:param name="currentPage"/><xsl:template match="/"><xsl:variable name="metaTitleValue" select="umbraco.library:Item($currentPage/@id, 'metaTitle')" /><!-- start writing XSLT --><xsl:choose> <xsl:when test="$metaTitleValue != ''"> <xsl:value-of select="$currentPage/metaTitle"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$currentPage/@nodeName"/> </xsl:otherwise></xsl:choose> </xsl:template></xsl:stylesheet>
Hi Amir,
If you want to be absolutely positively sure that there's nothing useful in the field, use the normalize-space() function:
<xsl:when test="normalize-space($metaTitleValue)">
- and if you want to do it all on one line (take metaTitle but fall back to @nodeName if empty):
<xsl:value-of select="($currentPage/@nodeName[not(normalize-space(../metaTitle))] | $currentPage/metaTitle)[1]">
/Chriztian
Thanks Chriztain!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
XSL:Choose always returning null
Hi,
I'm using the following xsl:choose statement to check for the "metaTItle" field in my master document type, it is constantly returning null. Am I missing something?
Thanks!
Amir
Got it!
Hi Amir,
If you want to be absolutely positively sure that there's nothing useful in the field, use the normalize-space() function:
- and if you want to do it all on one line (take metaTitle but fall back to @nodeName if empty):
/Chriztian
Thanks Chriztain!
is working on a reply...