I have the following XSLT that I am going to use to display a flash file that the user can change, at the moment it is trying to show the flash file by its ID but I of course want the url shown to make it work. I have tried a few different variations such as using Getniceurl but I cannot seem to get it to work. Can anyone help? I'm sure it is fairly simple.
<xsl:variable name="source" select="/macro/source"/> <xsl:variable name="swfFile" select="umbraco.library:GetXmlNodeById($source)/data [@alias='pagebanner1']"/> <xsl:template match="/"> <script type="text/javascript"> <![CDATA[ // Previous JavaScript code var path = "]]><xsl:value-of select="$source" /><![CDATA["; var videowidth = "]]>500<![CDATA["; var videoheight = "]]>100<![CDATA["; // Rest of JavaScript code var s1 = new SWFObject(path,"Pindar SWF",videowidth,videoheight,"9","#FFFFFF"); s1.addParam("allowfullscreen","true"); s1.addParam("allowscriptaccess","always"); s1.addParam("wmode","transparent"); s1.write("container"); ]]> </script> </xsl:template>
If you want to go down the route of allowing users to select the flash file and set the height and width, here's the media type I created to work with the above xslt
Thanks for the quick response, I have added your line of code and now when I look at the source it is inputting the url to the file but the javascript doesn't seem to be writing the div to the page, I now have the following XSLT, can you see why it would not be writing the div to the page that is showing the flash file?
<xsl:template match="/"> <div id="flashbanner"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player. </div> <script type="text/javascript" src="/scripts/swfobject.js"></script> <script type="text/javascript"> <![CDATA[ // Previous JavaScript code var path = "]]><xsl:value-of select="$swfFile" /><![CDATA["; var videowidth = "]]>500<![CDATA["; var videoheight = "]]>100<![CDATA["; // Rest of JavaScript code var s1 = new SWFObject(path,"Pindar SWF",videowidth,videoheight,"9","#FFFFFF"); s1.addParam("allowfullscreen","true"); s1.addParam("allowscriptaccess","always"); s1.addParam("wmode","transparent"); s1.write("flashbanner"); ]]> </script>
Also "Pindar SWF" could be changed (oops, should have done that myself) - it's the name of the client project where this xslt was originally developed!
Thanks for the response, it still doesn't seem to be working, I don't know too much about flash but it doesn't seem to be picking up the variables, this is the output I am getting and I would have thought that where it says:
var s1 = new SWFObject(path,videowidth,videoheight
It should be putting in the values from var path, var videowidth etc etc
<div id="flashbanner"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div><script type="text/javascript" src="/scripts/swfobject.js"></script><script type="text/javascript">
// Previous JavaScript code var path = "/media/80/revival.swf"; var videowidth = "100"; var videoheight = "200"; // Rest of JavaScript code var s1 = new SWFObject(path,videowidth,videoheight,"9","#FFFFFF"); s1.addParam("allowfullscreen","true"); s1.addParam("allowscriptaccess","always"); s1.addParam("wmode","transparent"); s1.write("flashbanner");
</script>
Once again this is the XSLT that I am using:
<xsl:variable name="source" select="/macro/source"/> <xsl:variable name="banner" select="/macro/banner"/> <xsl:variable name="swfFile" select="umbraco.library:GetMedia(umbraco.library:GetXmlNodeById($source)/data [@alias=$banner], 'false')/data [@alias = 'umbracoFile']"/> <xsl:variable name="height" select="umbraco.library:GetMedia(umbraco.library:GetXmlNodeById($source)/data [@alias=$banner], 'false')/data [@alias = 'videoheight']"/> <xsl:variable name="width" select="umbraco.library:GetMedia(umbraco.library:GetXmlNodeById($source)/data [@alias=$banner], 'false')/data [@alias = 'videowidth']"/> <xsl:template match="/"> <div id="flashbanner"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div> <script type="text/javascript" src="/scripts/swfobject.js"> </script> <script type="text/javascript"> <![CDATA[ // Previous JavaScript code var path = "]]><xsl:value-of select="$swfFile" /><![CDATA["; var videowidth = "]]><xsl:value-of select="$width" /><![CDATA["; var videoheight = "]]><xsl:value-of select="$height" /><![CDATA["; // Rest of JavaScript code var s1 = new SWFObject(path,videowidth,videoheight,"9","#FFFFFF"); s1.addParam("allowfullscreen","true"); s1.addParam("allowscriptaccess","always"); s1.addParam("wmode","transparent"); s1.write("flashbanner"); ]]> </script> </xsl:template>
You seem to be missing the "name" element, but you could make something up. I probably confused it a little by saying you could get rid of "pindar swf" as something does need to be there
var s1 =newSWFObject(path,"ANYNAME",videowidth,videoheight,"9","#FFFFFF");
Thanks for the quick response, I have added a name but still the output on the page is as follows, it doesn't seem to be putting the variables in but if I try adding <xsl:value-of select="$swfFile" /> directly to var s1 =new SWFObject then that will not work either:
<div id="flashbanner"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div><script type="text/javascript" src="/scripts/swfobject.js"></script><script type="text/javascript">
// Previous JavaScript code var path = "/media/80/revival.swf"; var videowidth = "100"; var videoheight = "200"; // Rest of JavaScript code var s1 = new SWFObject(path,flashbanner1,videowidth,videoheight,"9","#FFFFFF"); s1.addParam("allowfullscreen","true"); s1.addParam("allowscriptaccess","always"); s1.addParam("wmode","transparent"); s1.write("flashbanner");
I have tried that and I get the same output but the name now has quotes around it, am I missing some javascript code somewhere? Possibly some reference in my masterpage?
<div id="flashbanner"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div><script type="text/javascript" src="/scripts/swfobject.js"></script><script type="text/javascript">
// Previous JavaScript code var path = "/media/80/revival.swf"; var videowidth = "100"; var videoheight = "200"; // Rest of JavaScript code var s1 = new SWFObject(path,"flashbanner1",videowidth,videoheight,"9","#FFFFFF"); s1.addParam("allowfullscreen","true"); s1.addParam("allowscriptaccess","always"); s1.addParam("wmode","transparent"); s1.write("flashbanner");
I have included SWFObject, below is the full source output which shows the reference to it, I have also of course put swfobject in the file structcure, the javascript error I get is Uncaught ReferenceError: SWFObject is not defined which is for the line
var s1 = new SWFObject(path,"flashbanner1",videowidth,videoheight,"9","#FFFFFF");
<div id="movieplayer"> <div id="flashbanner"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player. </div><script type="text/javascript">
// Previous JavaScript code var path = "/media/80/revival.swf"; var videowidth = "100"; var videoheight = "200"; // Rest of JavaScript code var s1 = new SWFObject(path,"flashbanner1",videowidth,videoheight,"9","#FFFFFF"); s1.addParam("allowfullscreen","true"); s1.addParam("allowscriptaccess","always"); s1.addParam("wmode","transparent"); s1.write("flashbanner");
</script> movie player</div> <div id="movielist"> movie list </div>
Ok, I have managed to resolve it by changing the swfobject.js file I was using from the one on the website you suggested to an older version that I used on a previous website, not sure what the difference would be in the one from the website you suggested but it was causing it not to work? Maybe I downloaded the wrong file from the site?
Get url of flash file rather than node ID
Hi,
I have the following XSLT that I am going to use to display a flash file that the user can change, at the moment it is trying to show the flash file by its ID but I of course want the url shown to make it work. I have tried a few different variations such as using Getniceurl but I cannot seem to get it to work. Can anyone help? I'm sure it is fairly simple.
It looks like you might need to use getmedia (if the swfs are stored in the media library)
Here's what I use, allowing the users to choose the swf file using a mediacurrent macro parameter, and set the width and height for each flash file
Using mediacurrent the path is actually sent. You'll need to adjust the xslt to get the file
with yours it might be something like
Hope this helps
Dan
If you want to go down the route of allowing users to select the flash file and set the height and width, here's the media type I created to work with the above xslt
http://imgur.com/FNjHu.gif
Enjoy ;-)
Thanks for the quick response, I have added your line of code and now when I look at the source it is inputting the url to the file but the javascript doesn't seem to be writing the div to the page, I now have the following XSLT, can you see why it would not be writing the div to the page that is showing the flash file?
it could be that the script tag is self-closing due to output method of xml?
try
Otherwise you'll get
instead of
Also "Pindar SWF" could be changed (oops, should have done that myself) - it's the name of the client project where this xslt was originally developed!
Thanks for the response, it still doesn't seem to be working, I don't know too much about flash but it doesn't seem to be picking up the variables, this is the output I am getting and I would have thought that where it says:
var s1 = new SWFObject(path,videowidth,videoheight
It should be putting in the values from var path, var videowidth etc etc
Once again this is the XSLT that I am using:
Any suggestions on this? I was hoping that this was going to be a simple fix caused by my lack of knowledge of javascript and flashplayer!
You seem to be missing the "name" element, but you could make something up. I probably confused it a little by saying you could get rid of "pindar swf" as something does need to be there
-
Thanks for the quick response, I have added a name but still the output on the page is as follows, it doesn't seem to be putting the variables in but if I try adding <xsl:value-of select="$swfFile" /> directly to var s1 =new SWFObject then that will not work either:
The name should be a string, but you've sent it as a variable (that isn't yet defined). Stick quotes around flashbanner1 and see what happens!
I have tried that and I get the same output but the name now has quotes around it, am I missing some javascript code somewhere? Possibly some reference in my masterpage?
possibly you haven't included swfobject? http://code.google.com/p/swfobject/
Your code looks ok, but what error messages are you getting?
I have included SWFObject, below is the full source output which shows the reference to it, I have also of course put swfobject in the file structcure, the javascript error I get is Uncaught ReferenceError: SWFObject is not defined which is for the line
var s1 = new SWFObject(path,"flashbanner1",videowidth,videoheight,"9","#FFFFFF");
Ok, I have managed to resolve it by changing the swfobject.js file I was using from the one on the website you suggested to an older version that I used on a previous website, not sure what the difference would be in the one from the website you suggested but it was causing it not to work? Maybe I downloaded the wrong file from the site?
I've been using that embed code for around a year now, so perhaps the method has changed in the new version of swfobject.
*go check*
it's slightly different - here's the new format
I see, so it wasn't me being a numpty, thanks for all your help
is working on a reply...