I have a problem when trying to create/use a dynamic image field property.
I've created a document type property that allows people to select an image. I've also created a macro parameter that specifies the document type property that contains the image information.
I would like to use the macro information in the XSLT file, but when testing setup, the image is not loaded.
Dynamic image field name
Hi,
I have a problem when trying to create/use a dynamic image field property.
I've created a document type property that allows people to select an image. I've also created a macro parameter that specifies the document type property that contains the image information.
I would like to use the macro information in the XSLT file, but when testing setup, the image is not loaded.
How do I use dynamic node names?
I'm currently using...
<xsl:param name="currentPage"/>
<xsl:variable name="myImagePropertyName" select="/macro/ImagePropertyName"/>
<xsl:variable name="mediaId" select="number($currentPage/node [@nodeName=$myImagePropertyName])" />
...
Does anyone know i can fix this?
Kind regards
Tim
what version of umbraco are you using, cause your xpath expression seems wrong...
On a 4.5+ version use (assuming you're using the new xml schema, otherwise use 2nd code snippet)
<xsl:variable name="mediaId" select="number($currentPage [name() = $myImagePropertyName])" />
else, use
<xsl:variable name="mediaId" select="number($currentPage [@alias = $myImagePropertyName])" />
Hope this helps.
Regards,
/Dirk
Hi Dirk,
Thanks for your fast response. Currently I'm using 4.5.2
However, when trying out your solutions it doesn't work...
When replacing it with the actual image field name, it does work... strang...
<xsl:variable name="mediaId" select="number($currentPage/ImageField1)" />
My bad, should have checked before posting... :(
<xsl:variable name="mediaId" select="number($currentPage/* [name() = $myImagePropertyName])" />
Each property is a child node of the $currentPage node, so you need to add the '*'
Hope this helps.
Regards,
/Dirk
Hi Dirk,
Super ! It works great. Thanks for help.
Kind regards
Tim
is working on a reply...