Copied to clipboard

Flag this post as spam?

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


  • trfletch 598 posts 604 karma points
    Aug 19, 2009 @ 16:18
    trfletch
    0

    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.

     

    <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>
  • dandrayne 1138 posts 2262 karma points
    Aug 19, 2009 @ 16:29
    dandrayne
    0

    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

    <?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="html" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:variable name="videonode" select="/macro/SettingsNode"/>
    <xsl:variable name="videopath" select="$videonode/node/data[@alias='Video']"/>
    <xsl:variable name="videoheight" select="$videonode/node/data[@alias='VideoHeight']"/>
    <xsl:variable name="videowidth" select="$videonode/node/data[@alias='VideoWidth']"/>

    <!-- ============================================================= -->

    <xsl:template match="/">
    <div id="container"><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="$videopath" /><![CDATA[";
    var videowidth = "]]><xsl:value-of select="$videowidth" /><![CDATA[";
    var videoheight = "]]><xsl:value-of select="$videoheight" /><![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>
    <!-- ============================================================= -->

    </xsl:stylesheet>

    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

    <xsl:variable name="swfFile" select="umbraco.library:GetMedia(umbraco.library:GetXmlNodeById($source)/data [@alias='pagebanner1'], 'false')/data [@alias = 'umbracoFile']"/>

     

    Hope this helps

    Dan

     

  • dandrayne 1138 posts 2262 karma points
    Aug 19, 2009 @ 16:31
    dandrayne
    0

    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 ;-)

  • trfletch 598 posts 604 karma points
    Aug 19, 2009 @ 16:55
    trfletch
    0

    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: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: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>
    </xsl:template>
  • dandrayne 1138 posts 2262 karma points
    Aug 19, 2009 @ 17:17
    dandrayne
    0

    it could be that the script tag is self-closing due to output method of xml?

    try

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

    Otherwise you'll get

    <script type="text/javascript" src="/scripts/swfobject.js" />

    instead of

    <script type="text/javascript" src="/scripts/swfobject.js"></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!

     

  • trfletch 598 posts 604 karma points
    Aug 19, 2009 @ 17:43
    trfletch
    0

    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>
  • trfletch 598 posts 604 karma points
    Aug 20, 2009 @ 10:27
    trfletch
    0

    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!

  • dandrayne 1138 posts 2262 karma points
    Aug 20, 2009 @ 10:34
    dandrayne
    0

    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 = new SWFObject(path,"ANYNAME",videowidth,videoheight,"9","#FFFFFF");

    -

  • trfletch 598 posts 604 karma points
    Aug 20, 2009 @ 10:42
    trfletch
    0

    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");
     
    </script>
  • dandrayne 1138 posts 2262 karma points
    Aug 20, 2009 @ 11:22
    dandrayne
    0
    var s1 = new SWFObject(path,"flashbanner1",videowidth,videoheight,"9","#FFFFFF");

    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!

  • trfletch 598 posts 604 karma points
    Aug 20, 2009 @ 11:33
    trfletch
    0

    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");
     
    </script>
  • dandrayne 1138 posts 2262 karma points
    Aug 20, 2009 @ 11:39
    dandrayne
    0

    possibly you haven't included swfobject?  http://code.google.com/p/swfobject/

    Your code looks ok, but what error messages are you getting?

  • trfletch 598 posts 604 karma points
    Aug 20, 2009 @ 12:18
    trfletch
    0

    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");

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
     
    <head>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
    <script type="text/javascript" src="/scripts/swfobject.js">
    </script>
    <title>dasdas</title>
     <meta name="description" content='sdasd' />
     <meta name="keywords" content='asdasd' />
     
    <link href="/css/resets.css" rel="stylesheet" type="text/css" />
    <link href="/css/wonderful-default.css" rel="stylesheet" type="text/css" />
    <link href="/css/tonys.css" rel="stylesheet" type="text/css" />
    <link href="/css/menu.css" rel="stylesheet" type="text/css" />
     
     
    </head>
    <body>
    <form method="post" action="/life.aspx?" id="aspnetForm">
    <div>
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUENTM4MWRkfsMC/elanNWWKAcNPt59grV7jnU=" />
    </div>
     
    <div id="container">
    <b class="rtop"><b class="r1"></b> <b class="r2"></b><b class="r3"></b> <b class="r4"></b></b>
    <div id="logo"></div>
    <div id="banner1">
    </div>
    <div id="menu"><ul><li><a href="/"><span class="orangew">W</span>Home</a></li><li><a href="/life.aspx"><span class="orangew">W</span>life</a></li><li><a href="/community.aspx"><span class="orangew">W</span>community</a></li><li><a href="/training.aspx"><span class="orangew">W</span>training</a></li><li><a href="/contact.aspx"><span class="orangew">W</span>Contact</a></li></ul></div>
     
     
     <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>
     
    <div id="banner2and3">
    </div>
    <div id="footerlinks">FOOTER LINKS</div>
    </div>
    </form>
    </body>
    </html>
  • trfletch 598 posts 604 karma points
    Aug 20, 2009 @ 14:03
    trfletch
    0

    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?

  • dandrayne 1138 posts 2262 karma points
    Aug 20, 2009 @ 14:19
  • trfletch 598 posts 604 karma points
    Aug 20, 2009 @ 18:39
    trfletch
    0

    I see, so it wasn't me being a numpty, thanks for all your help

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies