Copied to clipboard

Flag this post as spam?

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


  • martin 259 posts 31 karma points
    Jul 21, 2009 @ 01:01
    martin
    0

    mediaCurrent as file picker = no go

    umbraco 3.05

    I am trying to use mediaCurrent in a macro to pick a pdf file so that it may be embedded in the web page.

    the xslt I am trying looks like:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library"
     exclude-result-prefixes="msxml umbraco.library">

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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->

    <xsl:variable name="pdfFile" select="/macro/pdfFile"/>

    <embed src="{$pdfFile}" width="500" height="600"></embed>

    </xsl:template>

    </xsl:stylesheet>

    so I drop the macro on a page, pick the pdf file but what get's displayed (viewing html source) is:

     

    <embed src="/media/1655/MY_PDF_FILE.pdfpdf1166235" width="500" height="600" />

     

     Is there another file picker I can use?

     

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jul 21, 2009 @ 10:33
    Douglas Robar
    1

    Very close!

    The object returned by the media picker (aka, media current) is a mediaType, which includes the filename, filetype, and size. You just want the filename portion, so change your variable to this:

    <xsl:variable name="pdfFile" select="/macro/pdfFile/data [@alias='umbracoFile']"/>

    cheers,
    doug.

  • martin 259 posts 31 karma points
    Jul 21, 2009 @ 17:35
    martin
    0

    Thanks for the reply. I changed the line as you suggested however the filename now returns a blank string:

    <embed src="" width="500" height="600" />

     

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 21, 2009 @ 17:44
    Dirk De Grave
    0

    Have you tried:

     

    <embed><xsl:attribute name="src"><xsl:value-of select="$pdfFile"/></xsl:attribute></embed>

     

    If still not working, try a copy-of of the pdfFile variable (look at source of the rendered page to view the output)

     

    Cheers,

    /Dirk

     

  • martin 259 posts 31 karma points
    Jul 21, 2009 @ 19:16
    martin
    0

    Dirk, I tried that and the result is:

    <embed src="" />

    I also tried:

    <xsl:copy-of select="$pdfFile" />

    when I use -> <xsl:variable name="pdfFile" select="/macro/pdfFile"/>
    copy-of returns "/media/1655/MY_PDF_FILE.pdfpdf1166235

    when I use -> <xsl:variable name="pdfFile" select="/macro/pdfFile/data [@alias='umbracoFile']"/>

    copy-of returns "<embed src=" width="500" height="600" />"

     

     

  • martin 259 posts 31 karma points
    Jul 21, 2009 @ 19:20
    martin
    0

    just to clarify I create the xslt and choose to have it create a macro that is "shown" in the editor, there is just one macro parameter :

    Alias: pdfFile

    Name: PDF File

    Type : mediaCurrent

     

    After I drop the macro on a page I get the media picker and I browse to a pdf file and select it...that's it

    am I missing something?

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jul 22, 2009 @ 12:17
    Douglas Robar
    100

    Try this.

    <xsl:variable name="pdfFile" select="/macro/pdfFile/node"/>
    <embed width="500" height="600">
        <xsl:attribute name="src">
            <xsl:value-of select="$pdfFile/data[@alias='umbracoFile']" />
        </xsl:attribute>
    </embed>

     

    If that doesn't work, can you do the following and show us the code you get back from the copy-of? You'll need to view the browser's source to see the full xml, and it's the xml that will tell us exactly what we need to know to give you the right xpath statement.

    <xsl:copy-of select="/macro/pdfFile" />

    cheers,
    doug.

  • martin 259 posts 31 karma points
    Jul 22, 2009 @ 23:20
    martin
    0

    Genious!

    Thank you very much Doug...

    so for anyone else needing to embed a pdf within a web page here is the full xslt:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library"
     exclude-result-prefixes="msxml umbraco.library">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <xsl:variable name="pdfFile" select="/macro/pdfFile/node"/>
    <embed width="796" height="1032">
        <xsl:attribute name="src">
        <xsl:value-of select="$pdfFile/data[@alias='umbracoFile']" />
        </xsl:attribute></embed>
    </xsl:template></xsl:stylesheet>

     

Please Sign in or register to post replies

Write your reply to:

Draft