Copied to clipboard

Flag this post as spam?

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


  • NightWolf 41 posts 44 karma points
    Oct 15, 2009 @ 03:08
    NightWolf
    0

    Custom media type with custom property not working in xslt

    I have a custom media type which provides the same properties as an image but also includes an additional field called Caption (alias: imageCaption) when I try accessing this in my macro it's returning an empty string, any ideas?

    <xsl:variable name="images" select="number($currentPage/data [@alias = 'galImages'])"/>

    <xsl:for-each select="umbraco.library:GetMedia($images, 'true')/node">
        <xsl:variable name="theNode" select="."/>
        <xsl:variable name="theTitle" select="./data [@alias = 'imageCaption']"/>

        <div class="imageCaption">
            <p><xsl:value-of select="$theTitle"/></p>
        </div>

    ...

     

    This is an extension of mtt_gallery, I assume I am missing something very simple and your help would be appreciated.

  • NightWolf 41 posts 44 karma points
    Oct 15, 2009 @ 08:37
    NightWolf
    0

    Just some further information if I output the variable theNode it contains the value of the imageCaption property

  • Ron Brouwer 273 posts 768 karma points
    Oct 16, 2009 @ 20:46
    Ron Brouwer
    0

    First of all why do you need the variable "theNode" since it is the current node. When selecting, it takes the content of the node, not the node itself.

    This is a sample of working xslt:

      <xsl:template match="/">
    <xsl:if test="string($currentPage/data [@alias = 'picFolder']) != ''">
    <xsl:for-each select="umbraco.library:GetMedia($currentPage/data [@alias = 'picFolder'],'true')//node">
    <xsl:if test="string(./data [@alias = 'umbracoFile']) != ''">
    <a title="{./data [@alias = 'description']}" href="/umbraco/ImageGen.ashx?image={./data [@alias = 'umbracoFile']}&amp;width=750&amp;height=500&amp;constrain=true&amp;format=jpg&amp;compression=85"><img alt="{./@nodeName}" src="/umbraco/ImageGen.ashx?image={./data [@alias = 'umbracoFile']}&amp;width=214&amp;height=136&amp;constrain=true&amp;format=jpg&amp;compression=85" /></a>
    </xsl:if>
    </xsl:for-each>
    </xsl:if>
    </xsl:template>

    If that does not help. Try using:

    <xsl:copy-of select="."/>

    Then you can see the xml you are working with. then you can look for typo problems.

    Ron

     

Please Sign in or register to post replies

Write your reply to:

Draft