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:
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.
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 " "> ]>
<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?
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.
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" />
Have you tried:
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
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" />"
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?
Try this.
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.
cheers,
doug.
Genious!
Thank you very much Doug...
so for anyone else needing to embed a pdf within a web page here is the full xslt:
is working on a reply...