Copied to clipboard

Flag this post as spam?

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


  • curlybub 133 posts 107 karma points
    Aug 06, 2010 @ 06:45
    curlybub
    0

    Display image from the parent node

    Hi umbraco people,

    This is my content structure:

    Content
      ---- Home
          ---- Model Line Up
              ---- Cars
                  ---- Lancer Evolution X (the xslt in this area)
                        ---- Features
                        ---- Specifications
                        ---- Gallery
                  ---- Lancer EX
                        ---- Features
                        ---- Specifications
                        ---- Gallery
                  ---- Galant
                        ---- Features
                        ---- Specifications
                        ---- Gallery
              ---- SUV
                  ---- Outlander

    I have a single image using media picker on Lancer Evolution X, Lancer EX and Galant. On the model line up section, the categories are listed and under them are the cars. When they choose a car, it redirects the user to the features section.

    What I want to do is to display the image from the car datatype when the user is redirected to the pages under it. I can make it work but performance suffers, im getting timeouts on the website. Im using this xslt to display the image:

    <xsl:if test="$currentPage/parent::node/data [@alias='modelNameImage'] != ''" >
     <img alt="{$currentPage/parent::node/@nodeName}">
      <xsl:attribute name="src">
       <xsl:value-of select="umbraco.library:GetMedia($currentPage/parent::node/data [@alias='modelNameImage'], 'false')/data [@alias='umbracoFile']" />
      </xsl:attribute>
     </img>
    </xsl:if>

    Are there other ways to get the image without making the performace of the site suffer?

    Thank you.


    Regards,
    Harry


  • Sascha Wolter 615 posts 1101 karma points
    Aug 06, 2010 @ 11:53
    Sascha Wolter
    1

    Hi curlybub,

    this is probably not what you want to hear but to me the code looks absolutely fine to me and shouldn't lead to any performance or even timeout problems. Only thing you could do might be to get the 'modelNameImage' value only one, so

    <xsl:variable name="modelId" select="$currentPage/parent::node/data[@alias='modelNameImage']" />

    Then use this in the if statement and on GetMedia. However it's probably more for cleaner code than performance as you also introduce another variable which will create some overhead as well.

    Cheers,
    Sascha

  • curlybub 133 posts 107 karma points
    Aug 06, 2010 @ 16:24
    curlybub
    0

    Thanks Sasha, I'll try that one out. ;D

Please Sign in or register to post replies

Write your reply to:

Draft