Copied to clipboard

Flag this post as spam?

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


  • Mikko Vartiainen 9 posts 29 karma points
    Apr 19, 2011 @ 17:28
    Mikko Vartiainen
    0

    Problems getting images from other nodes

    Hi,

    Needless to say, I've been starting out with Umbraco for a good while now, but I can't say I undestand much, if anything at all :)

    What I'm trying to achieve here is to create an XSLT I can call via a Macro on any random node, and that XSLT is supposed to get images (and later on some info relating to the images). For now I'm just trying to get the images.

    Under my root I have created a parent node (Vendors), and this parent node has a lot of children. Each child has and image called 'logotyp' picked with MediaPicker.

    I've checked here for reference, but all I get is
    Error parsing XSLT file...

    The code that I'm trying out looks like this (Supposed to be simple):

    <xsl:param name="currentPage"/>
    <xsl:variable name="rootNode" select="/macro/rootNode"/>
       
    <xsl:template match="/">
    <!-- start writing XSLT -->
      <h2>Tillverkare</h2>
        <xsl:for-each select="umbraco.library:GetXmlNodeById($rootNode)/descendant::* [@isDoc]">
          <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/logotyp, 0)" />

          <xsl:if test="$media">
             <img src="{$media/umbracoFile}" alt="{$media/altText}" />
          </xsl:if>
        </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

    Any Ideas would be greatly appreciated, as I just can't figure this one out.

    Thanks!


     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 19, 2011 @ 17:38
    Tom Fulton
    0

    Hi,

    You'll want to change the "media" variable to pull from the current item in the for-each loop, right now it's trying to pull from the current page.  Change to:

    <xsl:variable name="media" select="umbraco.library:GetMedia(logotyp, 0)" />

    If you still get the error, you might try wrapping the contents of your for-each loop in <xsl:if test="logotyp != ''"> ... </xsl:if> or try adding it as a condition to your for-each, ie [@isDoc][logotyp != '']

    Hope this helps,
    Tom

  • Mikko Vartiainen 9 posts 29 karma points
    Apr 19, 2011 @ 17:46
    Mikko Vartiainen
    0

    Yeah, thanks! Seems to be so easy when you guys work your magic :)

    $currentPage removed from the media variable and it worked directly.

    Thanks again!

Please Sign in or register to post replies

Write your reply to:

Draft