Copied to clipboard

Flag this post as spam?

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


  • Natasha 79 posts 195 karma points
    Feb 22, 2013 @ 17:08
    Natasha
    0

    Displayin Images from the carousel

    Hi all

    I am working on a simple carousel but want the user to select three images using the Digibiz Advanced Media picker.  I am using Umbraco 4.7.11 I have probably done something really silly but this XSLT isn't working for me. Can anyone help?

    Thanks in advance

    Natasha

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


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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <xsl:value-of select="umbraco.library:RegisterJavaScriptFile('cycle', '/Scripts/jquery.cycle/jquery.cycle.all.min.js')"/>
    <script type="text/javascript">
    function slideSwitch() {
    var $active = $('#banner IMG.active');

    if ( $active.length == 0 ) $active = $(#banner IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next = $active.next().length ? $active.next()
    : $('#banner IMG:first');

    // uncomment the 3 lines below to pull the images in random order

    // var $sibs = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, 1000, function() {
    $active.removeClass('active last-active');
    });
    }

    $(function() {
    setInterval( "slideSwitch()", 5000 );
    });
    </script>
    <xsl:variable name="bannerImages" select="umbraco.library:GetXmlNodeById($currentPage/@id)/bannerImages/*"/>

    <div id="banner">
    <xsl:if test="$bannerImages != '' and $bannerImages != false() ">

    <xsl:for-each select="umbraco.library:GetMedia($bannerImages, 1)/@nodeName">
    <img src="{umbracoFile}" alt="{@nodeName}" />

    </xsl:for-each>

    </xsl:if>

    </div>



    </xsl:template>

    </xsl:stylesheet>
  • Nigel Wilson 945 posts 2077 karma points
    Feb 23, 2013 @ 19:27
    Nigel Wilson
    0

    Hi Natasha

    Think you need to change the following line as you are outputting the node name within a "for-each" loop

    <xsl:for-eachselect="umbraco.library:GetMedia($bannerImages, 1)/@nodeName">

     Should this be the following?

    <xsl:for-eachselect="umbraco.library:GetMedia($bannerImages, 1)/Image">

    However I am not 100% sure this is what you are wanting based on the fact you are using DAMP.

    I would suggest adding the following so you can see the variable value - this may help provide direction (if needed)

    <xsl:variable name="bannerImages" select="umbraco.library:GetXmlNodeById($currentPage/@id)/bannerImages/*"/>
    <!-- Add this bit in below your variable and refresh the page -->
    <textarea>
    <xsl:copy-of select="$bannerImages"/>
    </textarea>

     

    Also noticed the following - it may not be an issue but thought I'd mention it now just in case (maybe help prevent further frustrations)

     

    var $active = $('#banner IMG.active');

     

    The "IMG" might be better as "img" just to be semantically correct with your html output / case sensitivity

    Hope the above helps

    Cheers, Nigel

Please Sign in or register to post replies

Write your reply to:

Draft