Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • lele 107 posts 444 karma points
    Mar 21, 2011 @ 10:26
    lele
    0

    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

     


  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 21, 2011 @ 11:15
    Kim Andersen
    0

    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

  • lele 107 posts 444 karma points
    Mar 21, 2011 @ 11:21
    lele
    0

    Hi Kim

    I use the build 4.7.0.378.

    wow, nice it works...

     

    thank you so much!

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 21, 2011 @ 11:56
    Kim Andersen
    1

    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

Please Sign in or register to post replies

Write your reply to:

Draft