Copied to clipboard

Flag this post as spam?

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


  • Klaus 47 posts 67 karma points
    Jul 22, 2011 @ 13:11
    Klaus
    0

    Use Image name as link name... ?

    hello,

    I have a XSLT file that display a PDF from my media directory. I use media picker to attach the pdf to a particular article.

    Now, I would like to give the link (to the pdf) the same name as when i named it in the media area.  (when i uploaded the file).

    As you can see from the following code, i have hard coded the name "Link til PDF" - I want the name to be the same as the file in the media directory. Hope you understand.

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:variable name="field" select="/macro/field" />
    <xsl:variable name="width" select="/macro/cssWidth" />
    <xsl:variable name="height" select="/macro/cssHeight" />
        
            <xsl:template match="/">
                    <xsl:apply-templates select="$currentPage/pdfItem[normalize-space()]" />
            </xsl:template>
            
            <xsl:template match="pdfItem">
                    <xsl:variable name="mediaNode" select="umbraco.library:GetMedia(., false())" />
                    <xsl:if test="not($mediaNode[error])">
                      <a href="{$mediaNode/umbracoFile}" width="{$mediaNode/umbracoWidth}" height="{$mediaNode/umbracoHeight}" alt="PDF link" />
                        Link til PDF
                      <a/>
                    </xsl:if>
            </xsl:template>

     

    Regards Klaus

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 22, 2011 @ 13:15
    Dennis Aaen
    1

    Hi Klaus,

    I think this will work for you. Try to put this in between the link tag.

    <xsl:value-of select="$mediaNode/@nodeName" />

    /Dennis

  • Klaus 47 posts 67 karma points
    Jul 22, 2011 @ 13:18
    Klaus
    0

    Hi Dennis,

    Lovely respones... thnaks

    I used this one instead <xsl:value-of select="umbraco.library:GetMedia($currentPage/pdfItem, 'false')/@nodeName"/>

    /Thanks anyway

     

    /Klaus

  • Kim Andersen 1447 posts 2196 karma points MVP
    Jul 22, 2011 @ 13:25
    Kim Andersen
    0

    Hi Klavs

    I'd go for Dennis' suggestion for sure.

    What you are doing is the excact same, UNLESS you're calling the GetMedia extension twice. This means that it'll performe slower than Dennis' sugestion.

    You've already grabbed the media item-XML in your $mediaNode-variable, so there's no reason to call the extension once more :)

    /Kim A

     

Please Sign in or register to post replies

Write your reply to:

Draft