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
I want to display an image, which is defined on the parent node over a media picker element (in a specific document type).
<xsl:if test="$currentPage/parent::node/data [@alias='mainIcon'] != ''" > <img alt="{$currentPage/parent::node/@nodeName}"> <xsl:attribute name="src"> <xsl:value-of select="umbraco.library:GetMedia($currentPage/parent::node/data [@alias='mainIcon'], 'false')/data [@alias='umbracoFile']" /> </xsl:attribute> </img></xsl:if>
But the mainIcon variable is always empty...
Have someone any idea why?
many thanks for your help
Hi lele
Which version of Umbraco are you using?
If it's one of the newer versions you should probably change your code to something like this:
<xsl:if test="$currentPage/parent::*[@isDoc]/mainIcon != ''"> <img alt="{$currentPage/parent::*[@isDoc]/@nodeName}"> <xsl:attribute name="src"> <xsl:value-of select="umbraco.library:GetMedia($currentPage/parent::*[@isDoc]/mainIcon, 0)/umbracoFile" /> </xsl:attribute> </img></xsl:if>
/Kim A
Hi Kim
I use the build 4.7.0.378.
wow, nice it works...
thank you so much!
Great to hear lele!
I think you can actually replace parent:: with a ../ like this:
<xsl:if test="$currentPage/../mainIcon != ''"> <img alt="{$currentPage/../@nodeName}"> <xsl:attribute name="src"> <xsl:value-of select="umbraco.library:GetMedia($currentPage/../mainIcon, 0)/umbracoFile" /> </xsl:attribute> </img></xsl:if>
*Should* give the same result, but a little more readable code :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Display an image from a parent node
I want to display an image, which is defined on the parent node over a media picker element (in a specific document type).
<xsl:if test="$currentPage/parent::node/data [@alias='mainIcon'] != ''" >
<img alt="{$currentPage/parent::node/@nodeName}">
<xsl:attribute name="src">
<xsl:value-of select="umbraco.library:GetMedia($currentPage/parent::node/data [@alias='mainIcon'], 'false')/data [@alias='umbracoFile']" />
</xsl:attribute>
</img>
</xsl:if>
But the mainIcon variable is always empty...
Have someone any idea why?
many thanks for your help
Hi lele
Which version of Umbraco are you using?
If it's one of the newer versions you should probably change your code to something like this:
<xsl:if test="$currentPage/parent::*[@isDoc]/mainIcon != ''">
<img alt="{$currentPage/parent::*[@isDoc]/@nodeName}">
<xsl:attribute name="src">
<xsl:value-of select="umbraco.library:GetMedia($currentPage/parent::*[@isDoc]/mainIcon, 0)/umbracoFile" />
</xsl:attribute>
</img>
</xsl:if>
/Kim A
Hi Kim
I use the build 4.7.0.378.
wow, nice it works...
thank you so much!
Great to hear lele!
I think you can actually replace parent:: with a ../ like this:
<xsl:if test="$currentPage/../mainIcon != ''">
<img alt="{$currentPage/../@nodeName}">
<xsl:attribute name="src">
<xsl:value-of select="umbraco.library:GetMedia($currentPage/../mainIcon, 0)/umbracoFile" />
</xsl:attribute>
</img>
</xsl:if>
*Should* give the same result, but a little more readable code :)
/Kim A
is working on a reply...