The built-in Umbraco properties (Id, nodeName etc.) are attributes as before, but custom properties are just named with the alias - so no more data[@alias = 'foo'] ...
Images are special - you need to call umbraco.library:GetImage(ID_HERE, false()) to get a chunk of XML from where you can grab width, height, extension etc.
Get properties Values
I bought access to Umbraco.TV in order to create a new page in a existing Umbraco site (4.5.1)
I want to be able to get in a page all information from all child nodes and I add a macro as:
<xsl:template match="/">
var refList = [
<xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
{
name: '<xsl:value-of select="@nodeName"/>',
logo: '<xsl:value-of select="data[@alias='logoImage']"/>',
img: '<xsl:value-of select="data[@alias='bigImage']"/>',
html: '<xsl:value-of select="data[@alias='htmlContent']"/>'
},</xsl:for-each>
];
</xsl:template>
So i'm looping through all child nodes and getting not only the name but the 3 properties I have for that Document Type:
http://www.balexandre.com/temp/2011-07-09_1652.png
But I'm getting all properties empty... what am I doing wrong?
Hi Bruno,
The syntax you've found uses the old legacy XML schema - the new one (since 4.6) makes it much easier:
The built-in Umbraco properties (Id, nodeName etc.) are attributes as before, but custom properties are just named with the alias - so no more data[@alias = 'foo'] ...
/Chriztian
PS: To get the Rich Text editor content as HTML output, use the disable-output-escaping flag:
/Chriztian
Got it, I can just use
<xsl:value-of select="logoImage"/>
:o)
P.S. I answered without seeing that I had 2 questions already... I think I'm to used to StackOverflow UI :(
Chriztian thank you for the disable output escaping part!
btw, the ImagePicker gives me a string Id, how can i convert it to the full path?
<xsl:value-of select="umbraco.library:NiceUrlFullPath(logoImage)"/>
code above complains about
System.OverflowException: Value was either too large or too small for an Int32.
and just as string(variable), I tried with
<xsl:value-of select="umbraco.library:NiceUrlFullPath(int(logoImage))"/>
and it complains again :(
Hi Bruno,
Images are special - you need to call umbraco.library:GetImage(ID_HERE, false()) to get a chunk of XML from where you can grab width, height, extension etc.
Read Lee Kelleher's blogpost about it here: http://blog.leekelleher.com/2010/08/11/how-to-use-umbraco-library-getmedia-in-xslt-for-umbraco-v4-5/
/Chriztian
Many thanks for the help.
I ended up using:
var refList = [
<xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
<xsl:variable name="varLogoImage" select="logoImage"/>
<xsl:variable name="varBigImage" select="bigImage"/>
{
name: '<xsl:value-of select="@nodeName"/>',
logo_id: '<xsl:value-of select="$varLogoImage" />',
logo_path: '<xsl:if test="string($varLogoImage) != ''">
<xsl:value-of select="umbraco.library:GetMedia($varLogoImage, 0)/umbracoFile" />
</xsl:if>',
imp_id: '<xsl:value-of select="$varBigImage" />',
img_path: '<xsl:if test="string($varBigImage) != ''">
<xsl:value-of select="umbraco.library:GetMedia($varBigImage, 0)/umbracoFile" />
</xsl:if>',
description: '<xsl:value-of select="htmlContent" disable-output-escaping="yes"/>'
},</xsl:for-each>
];
and the output is something like:
Company Big
Company Zyxel
Company DK_Aedelmetal
is working on a reply...