Copied to clipboard

Flag this post as spam?

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


  • Profiterole 232 posts 264 karma points
    May 11, 2010 @ 17:05
    Profiterole
    0

    Display a list of video by Youtube ID

    Hi all,

    I'm a teacher and my class students made about 30 videos to learn/remember school stuff. I'd like to display all these videos on the class website.

    I made a "video" datatype in which I entered all videos Youtube ID (like -j_JdG6s8hk for instance). Now that all my Youtube ID are entered in my content section in the "video" datatype, I'd like to create a macro who will display all these video on 1 page.

     

    So, would like to enter the parent node ID of my video, then the macro will look for child nodes and display all child videos. For now, it only display one video.

    <?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"
    xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltMath">

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

    <xsl:param name="currentPage"/>

    <xsl:variable name="parentNode" select="1113"/>

    <xsl:template match="/">

    <xsl:variable name="node" select="umbraco.library:GetXmlNodeById($parentNode)/node [position() = 1]"/>
    <xsl:value-of select="$node/@nodeName" /><br />
    <xsl:element name="object">
    <xsl:attribute name="type">application/x-shockwave-flash</xsl:attribute>
    <xsl:attribute name="width">425</xsl:attribute>
    <xsl:attribute name="height">344</xsl:attribute>
    <xsl:attribute name="class">youtube-embed</xsl:attribute>
    <xsl:attribute name="data">
    http://www.youtube.com/v/<xsl:value-of select="$node/data[@alias = 'youtube_id']" />
    </xsl:attribute>
    <xsl:element name="param">
    <xsl:attribute name="name">movie</xsl:attribute>
    <xsl:attribute name="value">
    http://www.youtube.com/v/<xsl:value-of select="$node/data[@alias = 'youtube_id']" />
    </xsl:attribute>
    </xsl:element>
    <xsl:element name="param">
    <xsl:attribute name="name">wmode</xsl:attribute>
    <xsl:attribute name="value">transparent</xsl:attribute>
    </xsl:element>
    <xsl:apply-templates mode="youtube-params" />
    </xsl:element>
    <br />

    </xsl:template>
    </xsl:stylesheet>

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 11, 2010 @ 17:13
    Dirk De Grave
    0

    Profiterole,

    I don't see any iteration in your xslt, so you can only have a single vid on your page right now, I guess you'll have to introduce a for-each in your script. And, currently your variable node will only hold a single node (as you have a position() = 1 constraint)

    <xsl:for-each select="umbraco.library:GetXmlNodeById($parentNode)/node">...</xsl:for-each>

    Hope this helps.

     

    Regards,

    /Dirk

     

     

  • Profiterole 232 posts 264 karma points
    May 11, 2010 @ 17:22
    Profiterole
    0

    Ok, thank you! Now I understand :)

    <?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">

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

    <xsl:param name="currentPage"/>

    <xsl:variable name="parentNode" select="1113"/>

    <xsl:template match="/">
    <xsl:for-each select="umbraco.library:GetXmlNodeById($parentNode)/node">
    <xsl:value-of select="@nodeName" /><br />
    <xsl:element name="object">
    <xsl:attribute name="type">application/x-shockwave-flash</xsl:attribute>
    <xsl:attribute name="width">425</xsl:attribute>
    <xsl:attribute name="height">344</xsl:attribute>
    <xsl:attribute name="class">youtube-embed</xsl:attribute>
    <xsl:attribute name="data">
    http://www.youtube.com/v/<xsl:value-of select="data[@alias = 'youtube_id']" />
    </xsl:attribute>
    <xsl:element name="param">
    <xsl:attribute name="name">movie</xsl:attribute>
    <xsl:attribute name="value">
    http://www.youtube.com/v/<xsl:value-of select="data[@alias = 'youtube_id']" />
    </xsl:attribute>
    </xsl:element>
    <xsl:element name="param">
    <xsl:attribute name="name">wmode</xsl:attribute>
    <xsl:attribute name="value">transparent</xsl:attribute>
    </xsl:element>
    <xsl:apply-templates mode="youtube-params" />
    </xsl:element>
    <br />
    </xsl:for-each>


    </xsl:template>
    </xsl:stylesheet>
  • ridi 71 posts 103 karma points
    Nov 11, 2010 @ 06:57
    ridi
    0

    is this code works in Umbraco 4.5.2?

  • Hundebol 167 posts 314 karma points
    Nov 11, 2010 @ 09:47
    Hundebol
    0

    Hi Ridi,

    No, the code does not work i 4.5.2 unless you are using the old XSLT Schema.

    The first thing you need to change is this

    <xsl:for-each select="umbraco.library:GetXmlNodeById($parentNode)/node">

    to

    <xsl:for-each select="umbraco.library:GetXmlNodeById($parentNode)/*">

    You also have to change

     http://www.youtube.com/v/<xsl:value-of select="data[@alias = 'youtube_id']" />

    But right now i can't remember how to write data["alias = 'youtube_id'] in the new XSLT Schema

    But i'm sure you can google your way to it :)

    best regards,
    Hundebol

Please Sign in or register to post replies

Write your reply to:

Draft