Copied to clipboard

Flag this post as spam?

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


  • Tim Melis 22 posts 43 karma points
    Apr 13, 2011 @ 16:01
    Tim Melis
    0

    Dynamic image field name

     

    Hi,

    I have a problem when trying to create/use a dynamic image field property.

    I've created a document type property that allows people to select an image. I've also created a macro parameter that specifies the document type property that contains the image information.

    I would like to use the macro information in the XSLT file, but when testing setup, the image is not loaded.

    How do I use dynamic node names?

    I'm currently using...

     

    <xsl:param name="currentPage"/>

    <xsl:variable name="myImagePropertyName" select="/macro/ImagePropertyName"/>

    <xsl:variable name="mediaId" select="number($currentPage/node [@nodeName=$myImagePropertyName])" /> 

    ...

     

    Does anyone know i can fix this?

    Kind regards

    Tim

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Apr 13, 2011 @ 16:14
    Dirk De Grave
    0

    what version of umbraco are you using, cause your xpath expression seems wrong...

    On a 4.5+ version use (assuming you're using the new xml schema, otherwise use 2nd code snippet)

    <xsl:variable name="mediaId" select="number($currentPage [name() = $myImagePropertyName])" /> 

    else, use

    <xsl:variable name="mediaId" select="number($currentPage [@alias = $myImagePropertyName])" /> 

     

    Hope this helps.

    Regards,

    /Dirk

  • Tim Melis 22 posts 43 karma points
    Apr 13, 2011 @ 16:34
    Tim Melis
    0

    Hi Dirk,

    Thanks for your fast response. Currently I'm using 4.5.2

    However, when trying out your solutions it doesn't work...

    When replacing it with the actual image field name, it does work... strang...

    <xsl:variable name="mediaId" select="number($currentPage/ImageField1)" /> 
    What could be wrong ?
    Tim

     

     

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Apr 13, 2011 @ 17:09
    Dirk De Grave
    1

    My bad, should have checked before posting... :(

    <xsl:variable name="mediaId" select="number($currentPage/* [name() = $myImagePropertyName])" /> 

    Each property is a child node of the $currentPage node, so you need to add the '*'

     

    Hope this helps.

    Regards,

    /Dirk

     

     

  • Tim Melis 22 posts 43 karma points
    Apr 13, 2011 @ 18:07
    Tim Melis
    0

    Hi Dirk,

    Super ! It works great. Thanks for help.

    Kind regards

    Tim

Please Sign in or register to post replies

Write your reply to:

Draft