Copied to clipboard

Flag this post as spam?

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


  • Laura Holland 82 posts 103 karma points
    Sep 12, 2011 @ 22:25
    Laura Holland
    0

    Linking to child node and displaying DAMP image from child node

    I know this must be simple, but I'm not brilliant with XSLT and I can't figure out how to generate this sort of output using a child node's DAMP image as the link:

    <a href="child node where DAMP image is from"><img src="DAMP image from child node"></a>

    I can display the DAMP image on the parent node, OR I can link to the child node, but I can't figure out how to do both in the same XSLT..

    Here's what I've got (link isn't working):

    <xsl:param name="currentPage"/>

      <xsl:template match="/">

        <xsl:for-each select="$currentPage/*/collectionsImages/DAMP/mediaItem">

          <xsl:apply-templates select="." />

        </xsl:for-each>

      </xsl:template>

      <xsl:template match="Image">
        <a href="{umbraco.library:NiceUrl(@id)}">
          <img src="{umbracoFile}" width="{umbracoWidth}" height="{umbracoHeight}" alt="{@nodeName}" />
        </a>
      </xsl:template>
  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Sep 12, 2011 @ 23:16
    Chriztian Steinmeier
    2

    Hi Laura,

    The @id you need to send to the NiceUrl() function should be taken from the page that *contains* the DAMP picker, right? Thus:

    <xsl:template match="Image">
        <a href="{umbraco.library:NiceUrl(ancestor::*[@isDoc][1]/@id)}">
            <img src="{umbracoFile}" width="{umbracoWidth}" height="{umbracoHeight}" alt="{@nodeName}" />
        </a>
    </xsl:template>

    The ancestor:: axis goes up the "parent" tree - we filter by [@isDoc] to only select Documents (not properties) and then we take the first we run into. From there, we grab the @id attribute. 

    /Chriztian 

  • Laura Holland 82 posts 103 karma points
    Sep 14, 2011 @ 15:23
    Laura Holland
    0

    Thank you so much Chriztian!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies