I am trying to create a credits page whereby a list is updated on the credits.aspx page ONLY if a field on an article has been completed, namely imageCredits.
I am struggling with the XSLT code to create this condition, this isn't helped as until now I have used XSLT to only create lists and other basic structure.
That kinda makes sense to me (like I say, I am an XSLT newby!!). Here is the code that I have so far, like I say I only want to display the info if something has been entered into the imageCredits field on the article.
Display HTML on a conditional basis
Hi guys,
I am trying to create a credits page whereby a list is updated on the credits.aspx page ONLY if a field on an article has been completed, namely imageCredits.
I am struggling with the XSLT code to create this condition, this isn't helped as until now I have used XSLT to only create lists and other basic structure.
Any help would be greatly appreciated guys.
Hi Brian
Could you post the XSLT you're currently working on? It will make it easier to help you out.
Cheers,
Jan
Hi Brian,
It goes like this:
To check if an element is present (i.e. actually exists in the XML):
To make sure it isn't empty (null, contains only whitespace etc.):
If the opposite test makes more sense to read at that point in your code, use the not() function, e.g.:
Ask away if you have other scenarios that doesn't work for you!
/Chriztian
Cheers guys,
That kinda makes sense to me (like I say, I am an XSLT newby!!). Here is the code that I have so far, like I say I only want to display the info if something has been entered into the imageCredits field on the article.
<?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" xmlns:umbraco.contour="urn:umbraco.contour" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour tagsLib BlogLibrary ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="numberOfItems">
<xsl:choose>
<xsl:when test="/macro/numberOfItems != ''">
<xsl:value-of select="/macro/numberOfItems"/>
</xsl:when>
<xsl:otherwise>9999999</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="imageCredits">
<xsl:if test="not($currentPage[imageCredits])">
</xsl:if>
</xsl:variable>
<xsl:template match="/">
<xsl:for-each select="$currentPage/parent::*/CareerFactoryArticleHome/DateFolder/child::*/CareerFactoryTextpage [@isDoc and string(imageCredits) != '1']">
<xsl:sort select="@createDate" order="descending" />
<xsl:if test="position() <= $numberOfItems">
<xsl:choose>
<xsl:when test="string($imageCredits) != '1'">
<div id="">
<h3><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></h3>
<div id="">
<p><xsl:value-of select="imageCredits" disable-output-escaping="yes"/></p>
<br />
<a href="{umbraco.library:NiceUrl(@id)}">Read this article</a>
</div>
</div>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
is working on a reply...