If you run through all of the childnodes from the current page with your for-each and want to show the showDate property on the each of the nodes that you run through then you should be able to grab those values by changing your code to somethins like this:
How to access node generic property
I created a generic propery for a document type. Now i want to access that property in xslt. I am new to umbraco. So i have no idea how to do this.
Hi There,
Assuming you are running umbraco 4.5 and the new schema you can access this property like so:
assuming the property is called "myProperty"
<xsl: value-of select="$currentPage/myProperty"/>
This will work if the XSLT macro is on the template of the document type that your property is associated with.
Hope this is what you are looking for.
L
Using XSLT
<?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:variable name="colorTop" select="string('#CCC')"/>
<xsl:variable name="color1" select="string('#EEE')"/>
<xsl:variable name="color2" select="string('#DDD')"/>
<xsl:template match="/">
<!-- The fun starts here -->
<table border="0" cellspacing="0" cellpadding="5">
<tr style="background-color: {$colorTop}">
<td><b>Name</b></td>
<td><b>Create Date</b></td>
<td><b>Custom Property</b></td>
</tr>
<xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
<tr>
<xsl:choose>
<xsl:when test="position() mod 2 = 0">
<xsl:attribute name="style">background-color: <xsl:value-of select="$color1"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">background-color: <xsl:value-of select="$color2"/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<td><a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</td>
<td>
<xsl:value-of select="umbraco.library:LongDate(@createDate)"/>
</td>
<td>
<xsl:value-of select="myAlias"/>
<xsl:value-of select="@id"/>
<xsl:value-of select="$currentPage/showDate"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
i want to access child node's generic property 'ShowDate'.
Hey Rajeev.
Is the showDate property on the child node of the $currentPage ? if so you could use:
<xsl:value-of select="$currentPage/child::*[@isDoc]/showDate"/>
This would return the showDate property of all the children under $currentPage.
L
OK ,But I am getting only last node's date in every iteration of loop.
<xsl:for-each select="$currentPage/child::*[@isDoc]/showDate">
<xsl:value-of select="umbraco.library:LongDate($currentPage/child::*[@isDoc]/showDate)"/>
</xsl:for-each>
I want to show individual date for each child node. Can you improve this loop.
thanks for your quick response.
Hi Rajeev
If you run through all of the childnodes from the current page with your for-each and want to show the showDate property on the each of the nodes that you run through then you should be able to grab those values by changing your code to somethins like this:
Actually you where almost there, but just need to change this line:
to this:
You'll probably not even need the ./ but I think that should work if I have understod you right :)
/Kim A
is working on a reply...