Copied to clipboard

Flag this post as spam?

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


  • stefan 3 posts 23 karma points
    Nov 08, 2011 @ 15:19
    stefan
    0

    Youtube video as Document Type?

    Hello all,

    New Umbraco user here. I am trying to create a Document Type that accepts a youtube < iframe > code as a parameter, to embed on a page. I've seen quite a few examples of youtube-macros, but i'd like to use it as a stand-alone 'object' on the page, not as a macro used in a content-area.

    I assume i would need a template that looks something like

    <xsl:template match="/">
    
     <xsl:variable name="url" name="videoUrl">
    
         <xsl:value-of select="data[@alias = 'url'])" />
    
     </xsl:variable>
    
     <iframe width="560" height="315" src=""{$videoUrl=""/data[@alias = 'url']}"" frameborder="0" allowfullscreen></iframe>
    
    </xsl:template>

    And then create a new document type that accepts a textstring as a parameter for the url, but I cant seem to get it to work. Can anyone tell me if im going in the right direction? :) Thanks!

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Nov 08, 2011 @ 15:31
    Jeroen Breuer
    0

    You might want to have a look at the uTube package. That might help.

    Jeroen

  • stefan 3 posts 23 karma points
    Nov 08, 2011 @ 15:37
    stefan
    0

    Hi Jeroen,

    Thanks for ur quick reply. I've looked at that package, I forgot to mention that I am working with Umbraco version 4.0.4.1, which i unfortunately cannot update at the time (not my decision). The uTube package is for versions 4.5 and higher it seems. I have to come up with some custom made solution i think.

    To be more specific:

    When I use a template like this:

    <xsl:template match="/">
    
     <object width="560" height="315">
     <param name="movie" value="http://www.youtube.com/v/MD5nU7kt7pg?version=3&hl=nl_NL">param> <param name="allowFullScreen" value="true">param> <param name="allowscriptaccess" value="always">param> <embed src="http://www.youtube.com/v/MD5nU7kt7pg?version=3&hl=nl_NL
    " type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true">embed> object> xsl:template>

    It renders the video fine, but once i try to send the video url through a Document Type like this:

    <xsl:template match="node[@nodeTypeAlias = 'MagazineYoutube']" mode="content">
    
     <xsl:variable name="videoUrl" select="@videoUrl" />
    
     <object width="560" height="315">
     <param name="movie" value="$videoUrl">param>  <param name="allowFullScreen" value="true">param>  <param name="allowscriptaccess" value="always">param>  <embed src="$videoUrl" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true">embed>  object> xsl:template>

    it renders the output like this:

    <object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/MD5nU7kt7pg?version=3&amp;hl=nl_NL&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/MD5nU7kt7pg?version=3&amp;hl=nl_NL&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>

    Also, version 4.0.4.1 does not support iframes yet?

    This following code renders an error System.Xml.XmlException: '>' is an unexpected token. The expected token is '='.

    <xsl:template match="/">
    <iframe width="560" height="315" src="http://www.youtube.com/embed/MD5nU7kt7pg" frameborder="0" allowfullscreen=""></iframe>
    </xsl:template>

     

     

     

     

     

  • stefan 3 posts 23 karma points
    Nov 09, 2011 @ 12:06
    stefan
    0

    Hi, for anyone that would like to achieve the same, here's my working solution:

    <xsl:template match="/">
     <xsl:variable name="urlVideo" select="data[@alias = 'urlVideo']" />
     <xsl:variable name="urlParts" select="umbraco.library:Split($urlVideo, '/')" />
     <embed src="http://www.youtube.com/v/{$urlParts/value[4]}"
    type="application/x-shockwave-flash"
    width="{data[@alias = 'positionWidth']}"
    height="{data[@alias = 'positionHeight']}"
    allowscriptaccess="always"
    allowfullscreen="true">
     </embed>
    </xsl:template>

    The end user can now embed a Youtube video with a Document Type that takes 3 parameters: urlVideo (textstring), positionWidth (numeric) and positionHeight (numeric).

     

  • 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